【发布时间】:2012-01-11 04:07:37
【问题描述】:
我有一个返回网页内容的方法:
private string FetchHTML(string sUrl, Encoding encoding)
{
System.Net.WebClient oClient = new System.Net.WebClient();
oClient.Encoding = encoding;
return System.Web.HttpUtility.HtmlDecode(oClient.DownloadString(sUrl));
}
但是,当我尝试从 livejournal 加载链接(例如,http://mos-jkh.livejournal.com/769579.html)时,我在 DownloadString 处收到此异常:
请求已中止:操作已超时。
这是一个已知问题吗?为什么 DownloadString 不适用于某些网页,是否有解决方案?或者是否有替代 DownloadString 的方法?
【问题讨论】:
-
除了您发布的链接之外,您能否举一个 URL 超时的示例?也许比 livejournal 有名气?查看您用于调用
FetchHTML的特定代码也将有所帮助(可能将任何变量替换为它们所代表的值)。