Resolving instances with ASP.NET Core DI from within ConfigureServices

How do I manually resolve a type using the ASP.NET Core MVC built-in dependency injection framework? Setting up the container is easy enough: public void ConfigureServices(IServiceCollection services) { // … services.AddTransient<ISomeService, SomeConcreteService>(); } But how can I resolve ISomeService without performing injection? For example, I want to do this: ISomeService service = services.Resolve<ISomeService>(); There are … Read more

How do you create a custom AuthorizeAttribute in ASP.NET Core?

I’m trying to make a custom authorization attribute in ASP.NET Core. In previous versions it was possible to override bool AuthorizeCore(HttpContextBase httpContext). But this no longer exists in AuthorizeAttribute. What is the current approach to make a custom AuthorizeAttribute? What I am trying to accomplish: I am receiving a session ID in the Header Authorization. … Read more