-
I have read about scopes in Microsoft DI and it seems that the main use case is for ASP.NET where a scope corresponds with handling of a single HTTP request. However, does Microsoft DI support adding a child scope to a scope?12 Footnotes |
Beta Was this translation helpful? Give feedback.
Answered by
davidfowl
Aug 8, 2024
Replies: 2 comments 4 replies
-
It does. You could use the using var provider = new ServiceCollection()
.AddScoped<Foo>()
.BuildServiceProvider();
using (var scope = provider.CreateScope())
{
var foo = scope.ServiceProvider.GetRequiredService<Foo>();
} However, Autofac is more configurable, e.g. you could register additional services when creating a child scope. |
Beta Was this translation helpful? Give feedback.
4 replies
-
There's no support for nested scopes. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MartyIX
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's no support for nested scopes.