Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'HttpClientFactory' does not exist in the current context

I'm writing an application in C#. It pulls the data from Cloudant NoSQL DB.

But when I'm trying to create the Http client:

HttpClient client = HttpClientFactory.Create(new LoggingHandler());

the compiler throws error saying that

'HttpClientFactory' does not exist in the current context

I have also included:

using System.Net.Http;"

at the top.

I still cannot find where the error is.

Could someone please throw some light.

like image 202
Anirban Avatar asked Oct 16 '15 16:10

Anirban


1 Answers

Install the Microsoft.AspNet.WebApi.Client nuget package.

VS -> Tools -> Nugetpackagemanager -> Package manager console

Install-Package Microsoft.AspNet.WebApi.Client

or (specific version)

Install-Package Microsoft.AspNet.WebApi.Client -Version 5.2.2

like image 144
Dhanuka777 Avatar answered Oct 23 '22 06:10

Dhanuka777