How long does it take to wait for a web request to return? I know this may be a bit loaded as a question, but all I'm trying to do is check if the webpage is accessible.
Maybe there is a better way?
try
{
HttpWebRequest request = WebRequest.Create(this.getUri()) as HttpWebRequest;
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Timeout = 120 * 1000;
if (request != null)
{
response = request.GetResponse() as HttpWebResponse;
connectedToUrl = processResponseCode(response);
}
else
{
logger.Fatal(getFatalMessage());
string error = string.Empty;
}
}
catch (WebException we)
{
...
}
catch (Exception e)
{
...
}
source
share