tags:

views:

107

answers:

2

How to set timeout when Unable to connect to the remote server in HttpRequest?

+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
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