XDocument xDoc = new XDocument();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Timeout = 1000 * 60 * 5;
WebResponse res = req.GetResponse();
Stream responseStream = res.GetResponseStream();
xDoc = XDocument.Load(responseStream);
responseStream.Close();
I am trying to use the above code to load a uri into an xdocument. I am using the HttpWebRequest and WebResponse to avoid the timeout error.
Now the problem is that most of the times the code does work but at the point where I was getting a "timeout" error before, now I am facing an "Internal server error (500)" when trying to use the above code. Any clues as to how to solve this issue? Code examples would be of great help.
Thanks!