Search code examples
asp.netxml.net-2.0response-time

XML Load TimeOut


I am using below code to load a xml:

XmlDocument xdoc = new XmlDocument();
xdoc.Load("http://mydomain.com/video/list");

in normal situation it works fine, but some times i face a issue of response time out. sometimes the url from which i wants to load my xml not response me and till that time my application also went timeout.

please tell me what should i do in such situation, so that either i can run my other code if it not responding me within 5 second or any other such solution in which i can do my code in case that url is not responding me xml file.

Thanks


Solution

  • You could try using a HttpWebRequest where you have the possibility to set the TimeOut for the request. In the case the remote resource doesn't response before this timeout value is reached an exception will be thrown which you could intercept and inform the user.