目標平臺:Windows 8.1System.Net.WebException無法解析google.com
我這個簡單的代碼
using System;
using System.IO;
using System.Net;
using System.Diagnostics
public static async void DownloadFile(string url)
{
HttpWebRequest request = WebRequest.CreateHttp(url);
WebResponse resp = await request.GetResponseAsync();
System.IO.Stream stream = resp.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
Debug.WriteLine("content:" + reader.ReadToEnd());
}
現在,當我這樣調用
DownloadFile("https://www.google.com/");
此功能它閒置了一段時間,大約過了10秒鐘後,我在GetResponseAsync-line中得到一個System.Net.WebException。
附加信息:遠程名稱無法解析:'www.google.com'
這發生在每個網址。是的,我的電腦有互聯網,沒有我不使用代理服務器,我懷疑google.com不會被防火牆取代。
你可以嘗試刷新DNS緩存 - ipconfig/flushdns – Stamen
這沒有幫助,但謝謝。 – Nozdrum
也許你的程序是被防火牆阻止的程序...嘗試在你的程序的防火牆規則中添加一個異常(請記住添加'* .vshost.exe') –