我遇到了問題HttpClient
,我不斷收到HttpRequestException occurred in mscorlib.dll
。我已經從SVN下載了以前的工作版本,並且不斷收到相同的異常。HttpClient HttpRequestException
爲什麼我突然得到這個異常,即使我正在運行一直工作正常的數週的代碼?
現在,我想用這個簡單的代碼進行調試,但我得到了同樣的異常無論我做什麼
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept
.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(
"application/json"));
HttpResponseMessage response
= await client.GetAsync("http://api.themoviedb.org/3/movie/550?api_key=x");
return await response.Content.ReadAsStringAsync();
我的InnerException如下:
The remote name could not be resolved:
api.themoviedb.org System.Exception System.Net.WebException
我得到相同對於我嘗試的每個網址,他們都在我的瀏覽器中工作。 這裏是例外,堆棧跟蹤:
res "System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.Net.WebException: The remote name could not be resolved: 'api.themoviedb.org'
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
什麼是完整的異常錯誤? – ChrisBint 2013-02-28 18:41:01
您使用的是代理服務器嗎? – ChrisBint 2013-02-28 18:42:54
水庫\t「System.Net.Http.HttpRequestException:發送請求時發生錯誤---> System.Net.WebException:遠程名稱無法解析:api.themoviedb.org'\ r \ n在System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\ r \ n在System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)\ r \ n ---內部異常堆棧跟蹤結束--- \ r \ n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務任務)\ r \ n – 2013-02-28 18:45:27