Mid
ASP.NET Core
ASP.NET Core
Using IServiceProvider / IServiceScopeFactory?
- IServiceProvider: Resolves services manually.
- IServiceScopeFactory: Creates a new DI scope (useful for background tasks).
using (var scope = serviceScopeFactory.CreateScope())
{
var scopedService =
scope.ServiceProvider.GetRequiredService<IMyScopedService>();
}Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png