考虑以下URL:“ http://www.bestbuy.com”。此资源可以在所有浏览器中以及从所有位置快速正确地加载。
但是,当前该网址的基本C#代码卡住了(对于任何超时,超时都结束了):
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var req = WebRequest.CreateHttp("http://www.bestbuy.com");
req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
req.Timeout = 30000; // you can set any timeout
using (var resp = (HttpWebResponse)req.GetResponse()) // stucks and finally ends by timeout here
{
Console.WriteLine(resp.StatusCode);
Console.WriteLine(resp.ResponseUri.AbsoluteUri);
}
提琴:https://dotnetfiddle.net/M7NZgG
对于大多数其他URL,相同的代码也可以正常工作。
尝试了不同的方法,但所有方法都无济于事:
HttpClient类也因该资源超时而阻塞并结束。
答案 0 :(得分:-1)
im 10 rep缺少评论,这个答案应该在哪里,所以请不要拒绝投票,我只是想知道,您是否尝试期望:100-继续?至少会延迟将您的回复分散为两次回报,可能会告诉您更多信息。