-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
I'm looking for some informations related to the lifetime of IServiceScopeFactory
and IServiceProvider
when they are injected inside of a custom service, an MVC controller or an hosted service.
Based on my understanding, IServiceScopeFactory
is automatically registered with the dependency injection system as a singleton service. Is my understanding correct ?
My doubt are related to the injection of IServiceProvider
, because there is a root service provider and several children service providers (one per each scope defined when an HTTP request is handled by the ASP.NET core application).
When I request an instance of IServiceProvider
from the constructor of an MVC controller do I get the root container or a child container for the scope of the current HTTP request ?
What about the injection of IServiceProvider
in the constructor of an hosted service ? In that case the root container is inject, right ?
Thanks for helping.
Enrico.