我正在.net Framework3.5中开发一个手机应用程序,它使用一个API服务调用来检查来自网站的电子邮件地址。
using System.Net.Http;
HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);
最初我使用WebClient
而不是HttpClient
,我在谷歌得到了这个错误"The type or namespace name 'WebClient' could not be found
“,并用HttpClient
修复了这个问题。
在用HttpClient
替换WebClient
之后,我得到了这个错误"The type or namespace name 'Http' does not exist in the namespace 'System.Net
“。
需要帮助来解决这个问题。
谢谢
发布于 2014-06-09 20:44:09
HttpClient
在带有Microsoft.Net.Http NuGet软件包的.NET 4.5或4.0中可用。它完全不适用于.NET 3.5。
HttpClient
使用仅在.NET 4+中可用的功能,如第三方许可证。
您必须使用System.Net.WebClient或WebRequest。如果遇到任何编译错误,请确保添加了正确的using
语句。这两个类从.NET 1.1开始在System.dll
库中可用,因此始终可用。
https://stackoverflow.com/questions/24120543
复制相似问题