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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With