Quantcast
Channel: Unable to resolve service for type 'System.Net.Http.HttpClient' - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by Sibeesh Venu for Unable to resolve service for type...

I was getting a similar error in my Azure Function Version 2. As per this document, we should be able to add the IHttpClientFactory as a dependency. After adding this DI in my Azure Function, I was...

View Article



Answer by Petr Mašlaň for Unable to resolve service for type...

I had a similar problem - the problem was in double registration: services.AddHttpClient<Service>(); services.AddSingleton<Service>(); // fixed by removing this line

View Article

Answer by Kirk Larkin for Unable to resolve service for type...

TLDR; ViewComponents do not support typed clients out of the box. To resolve this, add a call to AddViewComponentsAsServices() onto the end of the call to services.AddMvc(...). After a pretty long chat...

View Article

Answer by Henk Mollema for Unable to resolve service for type...

It seems that you've got two view components mixed up. You're registering the FixturesViewComponent as a "named HTTP client" yet you attempt to inject an HttpClient instance in the...

View Article

Unable to resolve service for type 'System.Net.Http.HttpClient'

I created a ViewComponent class which call a REST API using the HttpClient, this is the code: public class ProductsViewComponent : ViewComponent { private readonly HttpClient _client; public...

View Article


Answer by Martin Dekker for Unable to resolve service for type...

I had a similar error message trying to inject a wrapper for an external REST service to my controller as an interface. I needed to change the following in...

View Article

Answer by aiodintsov for Unable to resolve service for type...

Maybe it will help, but in my situation this worked:public void ConfigureServices(IServiceCollection services){ services.AddTransient<IMyService,MyService>(); // my usual DI injection of a...

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images