You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2018. It is now read-only.
I really like the idea of HttpClientFactory, but have found issues that the convenience methods assume you have singleton instances of the services required. For instance, the following fails:
publicvoidConfigureServices(IServiceCollectionservices){services.AddScoped<Test2>();// Works if I switch this to AddSingletonservices.AddHttpClient<Test1>();services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);}publicclassTest1{publicTest1(HttpClientclient,Test2test2){}}publicclassTest2{}
This results in the following:
InvalidOperationException: Cannot resolve scoped service 'WebApplication1.Startup+Test2' from root provider.
Can there be a way to set the lifetime of the scope? In this example, I want to set Test1 as a singleton.
I really like the idea of HttpClientFactory, but have found issues that the convenience methods assume you have singleton instances of the services required. For instance, the following fails:
This results in the following:
Can there be a way to set the lifetime of the scope? In this example, I want to set
Test1as a singleton.