Net Core Dependency Injection for Non-Controller
You can easily define a static class with one property like: public static class StaticServiceProvider { public static IServiceProvider Provider { get; set; } } after defined class you have to scope the service in the Startup.ConfigureServices method: public void ConfigureServices(IServiceCollection services) { //TODO: … services.AddScoped<IUnitOfWork, HttpUnitOfWork>(); services.AddSingleton<ISomeInterface, ISomeImplementation>(); } then inside the Startup.Configure method … Read more