我在使用WebClient.DownloadString()时遇到了一个奇怪的问题。这是非常非常慢,有时不工作,但如果我尝试浏览使用IE9/Chrome的网站,一切正常。
代码如下:
var req = new WebClient();
req.Encoding = Encoding.UTF8;
string result = string.Empty;
result = req.DownloadString(someURL);有什么想法吗?
发布于 2011-10-24 20:19:07
您发送的代码片段是正确的( string result = string.Empty;中的一部分完全没有意义)。如果你觉得应用程序阻塞了,你应该考虑使用DownloadStringAsync。
发布于 2011-10-24 20:22:23
尝试将WebClient.Proxy设置为GlobalProxySelection.GetEmptyWebProxy
https://stackoverflow.com/questions/7875364
复制相似问题