How to increase the timeout when connecting to a remote server uwing HttpWebRequest?
Asked
Active
Viewed 881 times
0
-
1Please clarify. If you use System.Web.HttpRequest, it is typically instantiated by the ASP.NET runtime and you don't get to control the timeout on the server side. Or do you refer to System.Net.HttpWebRequest perhaps? – Guido Domenici May 04 '10 at 09:30
2 Answers
1
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
- 1,488
- 11
- 20
0
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.

Community
- 1
- 1

David Perlman
- 1,460
- 1
- 12
- 32