When working with ASP.NET Core and it’s Dependency Injection container, you will likely run into an error that’s similar to this one: Some services are not able to be constructed (Error while validating the service descriptor ‘ServiceType: AspNetCoreDi.IMyConnectionManager Lifetime: Singleton ImplementationType: AspNetCoreDi.MyConnectionManager’: Cannot consume scoped service ‘AspNetCoreDi.IMyScopedService’ from singleton ‘AspNetCoreDi.IMyConnectionManager’.) This happens when you have […]
Continue readingThe problem You have an application that you need to show off to your friends or a client, and they all need to access it online, and you don’t want to use your old server in your basement. If it’s a small application, you can easily do all this for FREE! You got: ASP.NET Core […]
Continue readingHow we (some of us?) do Model validation right now We, developers, use a lot of repetitive code in our ASP.NET (Core) Web API / MVC actions. Inside of our controller actions we usually check if the model is valid by using ModelState property available on MVC’s base controller class: View the code on Gist. The […]
Continue readingUnit Testing – IAuthorizationService, Requirement and Handler You have a controller that makes use of IAuthorizationService and you have a custom requirement – implementation of IAuthorizationRequirement. You might also have your custom handler which is an implementation of IAuthorizationHandler. As an honourable .NET Core citizen, you are doing some unit tests for your controller and […]
Continue readingTL;DR Add following line to your .csproj file: <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish> Introduction I was publishing a project I am working on to web server (Linux) and I had an issue with Razor Pages. However, it seems that this error occurs only when you precompile your Razor views (MVC views, Razor Pages). Why would you do that? Well, […]
Continue reading