I am trying to use HttpClient in my .net core 2.0 project and for that I have injected HttpClient in my controller. But when I am trying to configure httpclient in my startup.cs I am getting this error: "IServiceCollection does not contain a defintion for AddHttpClient". I have already referenced using Microsoft.AspNetCore.Http;
and using Microsoft.Extensions.DependencyInjection;
and here is what I am trying to do:
services.AddHttpClient<TestController>();
It's working fine in other project with same namespaces but here I am getting the error. Any help?
Aah, I have found the solution. I think services.AddHttpClient
work with .net core 2.1. So I updated my .net core version to 2.1 and updated the microsoft packages to 2.1 and it starts working.