【发布时间】:2011-04-02 15:40:56
【问题描述】:
有时我在通过 URL 读取 XML 时遇到超时异常。我可以做些什么来防止这种情况发生,还是远程服务器有问题?下面是我的简单代码:
XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(this.RssUrl));
我看到一篇帖子说 KeepAlive 可能会有所帮助,但我不知道如何将该设置传递到上面的代码中(或者这是否是正确的解决方案):http://www.velocityreviews.com/forums/t95843-system-webexception-the-operation-has-timed-out.html
这是个例外,请帮忙!
Exception Details: System.Net.WebException: The operation has timed out
Stack Trace:
[WebException: The operation has timed out]
System.Net.HttpWebRequest.GetResponse() +5375213
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials) +69
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +3929371
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext) +144
System.Xml.XmlReader.Create(String inputUri) +8
【问题讨论】:
标签: c# .net asp.net .net-3.5 xmlhttprequest