Is there any way to register service in asp.net core as Scoped to request not to current request scope?
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IMyService, MyService>();
}
After registration service is available in request scope, but as soon as I create new child scope:
var service1 = serviceProvider.GetService<IMyService>();
var scope = serviceProvider.CreateScope();
var service2 = scope.ServiceProvider.GetService<IMyService>();
Service1 and service2 are 2 instances. Even if child scope is created in the same request. Is there a way to register service to request scope so all child scopes created from the same request scope would have the same one instance?