Reputation: 7348
How to increase the timeout when connecting to a remote server uwing HttpWebRequest?
Upvotes: 0
Views: 890
Reputation: 1470
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.
Upvotes: 0
Reputation: 1533
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();
Upvotes: 1