This repository was archived by the owner on Nov 20, 2018. It is now read-only.
IApplicationBuilder.ApplicationServices instance, returns different scoped services/objects from 'HttpContext.RequestServices instance #697
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Suppose that I registered a scoped service.
services.AddScoped<IMyService, MyService>();
Now, consider the following scenario... On startup class:
Consider that I'm trying to use IMyService implementation inside of MyFileProvider, but that would happen just when a request comes in. During the same request as the "Use" method, the MyService instance is being created again (same request/same thread, just accessed by IServiceProvider (from IApplicationBuilder.ApplicationServices) instead of IServiceProvider (from HttpContext.RequestServices).
Anyway, since the service was defined scoped. Is that supposed to be a normal behavior?
The text was updated successfully, but these errors were encountered: