How to set timeout when Unable to connect to the remote server in HttpRequest?
views:
107answers:
2
+1
A:
If you're using HttpWebRequest, you should set Timeout to the desired value:
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
request.Timeout = 5000 // in ms, the default is 100,000
request.GetResponse();
dpurrington
2010-05-04 09:33:59
A:
First off there is HttpWebRequest.Timeout
. Details Here (and in the answer that was posted while I was typing)..
Second I would suggest using System.Net.WebClient
which has a very simple to use interface. Setting a timeout on a WebClient is explained here.
ondesertverge
2010-05-04 09:35:43