Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace 'HttpClient' could not be found

Tags:

c#

.net

I am losing my mind over this reference error. I've added the Microsoft.Net.Http Nuget package, made sure the System.Net.Http reference is added to the page, imported the System.Net.Http namespace to the class. Nothing. I even went as far as to recreate the project from scratch using a blank template.

Can someone offer some ideas? Thanks!

like image 302
christok Avatar asked Jan 20 '16 13:01

christok


People also ask

What is the namespace for HttpClient?

The HttpClient class resides on the System. Net. Http namespace, which is a brand new . NET 4.5 namespace.

What is an HttpClient in C#?

HttpClient class provides a base class for sending/receiving the HTTP requests/responses from a URL. It is a supported async feature of . NET framework. HttpClient is able to process multiple concurrent requests. It is a layer over HttpWebRequest and HttpWebResponse.


2 Answers

Not sure if you have already tried this, but:

All I did was add the System.Net.Http in the project references.

In the Project Explorer, right click references -> add reference, then tick the relevant checkbox from the list of dlls and click OK

like image 176
InsideTrack Avatar answered Sep 20 '22 05:09

InsideTrack


In my visual studio 2017 Xamarin.forms project I had the same problem. If I right click my solution, there is the "Manage NuGet packages..." If I select it, in the "Browse", I look for "System.net" I selected the found item, enter image description here checked the checkboxes for the project and clicked "Install"

like image 28
frans eilering Avatar answered Sep 19 '22 05:09

frans eilering