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

I am developing a mobile phone application in the .net framework 3.5, which uses an API service call to verify the email address from the site. I use the code below to execute this

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

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

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

Need help to solve this problem.

thanks

+7
c # visual-studio wpf
source share
1 answer

HttpClient is available in .NET 4.5 or 4.0 with the Microsoft.Net.Http NuGet package. It is not available for .NET 3.5.

HttpClient uses features such as TPL that are only available in .NET 4+.

You will need to use System.Net.WebClient or WebRequest . If you get any compilation errors, make sure you add the correct using statements. These two classes are available with .NET 1.1 in the System.dll library and are therefore always available.

+7
source

All Articles