你有沒有嘗試設置HttpWebRequest的Host屬性? 這可能是您的問題的原因。
我也安裝了.NET 4.5並遇到同樣的情況。 當提琴手運行時,我得到相同的錯誤和充當代理。錯誤是:
System.Net.WebException:操作已在 System.Net.HttpWebRequest.GetResponse()超時
這裏是能重現問題一個微不足道的樣品:
using System;
using System.IO;
using System.Net;
namespace WebRequestTest
{
class Program
{
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
request.Host = "www.microsoft.com";//If I comment this line, capturing with fiddler works OK.
request.Method = "GET";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader sr = new StreamReader(stream))
{
string content = sr.ReadToEnd();
Console.WriteLine(content);
}
}
}
}
在我的情況,我只是不得不評論request.Host="www.microsoft.com"
線,一切工作正常。
我懷疑在使用除代理以外的HTTP代理時會發生相同的行爲,但我沒有經過測試。
您需要提供更多詳細信息; Fiddler在安裝.NET4.5的時候工作得很好,我每天都在這裏使用它。你的machine.config或app.config是否指定了一個代理?如果您的客戶請求http://127.0.0.1:8888/會發生什麼? – EricLaw
我來自Microsoft .NET Framework兼容性團隊。我們無法重現該問題。如果您能夠重現此問題,請通過Microsoft dot com的netfx45compat與我們聯繫。謝謝 – Varun