[英]The type or namespace name 'Http' does not exist in the namespace 'System.Web'
[英]The type or namespace name 'Http' does not exist in the namespace 'System.Net'
我正在開發.net framework 3.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
”google並使用HttpClient
修復此問題。
用HttpClient
替換WebClient
,我收到此錯誤“ The type or namespace name 'Http' does not exist in the namespace 'System.Net
。
需要幫助來解決這個問題。
謝謝
HttpClient
在.NET 4.5或4.0中可用,帶有Microsoft.Net.Http NuGet包。 它完全不適用於.NET 3.5。
HttpClient
使用僅在.NET 4+中可用的TPL等功能。
您必須使用System.Net.WebClient或WebRequest 。 如果出現任何編譯錯誤,請確保添加了正確的using
語句。 自.NET 1.1以來,這兩個類在System.dll
庫中可用,因此始終可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.