Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type or namespace name 'Http' does not exist in the namespace 'System.Net'

I am developing a handset application in .net framework 3.5,which is using an API service call to check the email address from website.I am using the below code to perform that,

using System.Net.Http;

HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);

Initially i used WebClient instead of HttpClient and i got this error "The type or namespace name 'WebClient' could not be found" google and fixed this with HttpClient.

After replacing WebClient with HttpClient i am getting this error "The type or namespace name 'Http' does not exist in the namespace 'System.Net".

Need help to solve this.

Thanks

like image 419
user3100575 Avatar asked Jun 09 '14 12:06

user3100575


People also ask

What is System Net HTTP?

Provides a programming interface for modern HTTP applications, including HTTP client components that allow applications to consume web services over HTTP and HTTP components that can be used by both clients and servers for parsing HTTP headers.

What is System net in C#?

Classes in the System.Net namespace can be used to develop Windows Store apps or desktop apps. When used in a Windows Store app, classes in the System.Net namespace are affected by network isolation feature, part of the application security model used by the Windows Developer Preview.


1 Answers

HttpClient is available in .NET 4.5 or 4.0 with the Microsoft.Net.Http NuGet package. It isn't at all available for .NET 3.5.

HttpClient uses features like the TPL that are only available in .NET 4+.

You'll have to use either System.Net.WebClient or a WebRequest. If you get any compilation errors, make sure you've added the proper using statements. These two classes are available since .NET 1.1, in the System.dll library and thus are always available.

like image 87
Panagiotis Kanavos Avatar answered Oct 17 '22 05:10

Panagiotis Kanavos