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
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 theSystem.dll
library and thus are always available.