'HttpClientFactory' does not exist in the current context

10,336

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

Share:
10,336
Anirban
Author by

Anirban

Updated on June 18, 2022

Comments

  • Anirban
    Anirban almost 2 years

    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.

  • Donny V.
    Donny V. over 7 years
    This fixes the HttpClientFactory issue but usually your using other libraries that are brought over from installing the Microsoft.AspNet.WebApi.Client nuget package also.
  • Edza
    Edza about 2 years
    WARNING! It is Microsoft.Extensions.Http :)
  • Fábio Rodrigues Fonseca
    Fábio Rodrigues Fonseca about 2 years
    Tk's @Edza Edited