ralphtrent
Programmer
Hello
I need to access a website so often to make sure it is up and available to users. (Long story short, it is a 1.1 web app running on windows 2003 and for some reason, the site keeps betting put in app pools that cause it to break). So I have a service that runs the following code:
I always end of getting an email even if the site is up. I can access the same website on the computer this service is running on using IE but in code I aways seem to not be able to connect. I also had this code
When I do this, I would get a TimeOut error. I am not sure why. According to the MSDN the HttpWebRequest.TimeOut default value is 100 seconds, but I get an error with-in 10.
Any clue how I can check for the sites availability if this is not the most accurate way or any idea why I can not get this code to execute correctly?
Thanks,
RalphTrent
I need to access a website so often to make sure it is up and available to users. (Long story short, it is a 1.1 web app running on windows 2003 and for some reason, the site keeps betting put in app pools that cause it to break). So I have a service that runs the following code:
Code:
string lstrURL = Convert.ToString(ldrAlert["USER_01_VALUE"], System.Globalization.CultureInfo.CurrentCulture);
string lstrPageContent = "Empty";
HttpWebRequest lwhwrWebRequestObject ;
try
{
lwhwrWebRequestObject = (HttpWebRequest)HttpWebRequest.Create(lstrURL);
if (!lwhwrWebRequestObject.HaveResponse)
{
throw new System.Net.WebException();
}
}
catch (System.Net.WebException)
{
TODO:SEND ME AN EMAIL
}
finally
{
lwhwrWebRequestObject = null;
}
I always end of getting an email even if the site is up. I can access the same website on the computer this service is running on using IE but in code I aways seem to not be able to connect. I also had this code
Code:
lwhwrWebRequestObject.GetResponse()
When I do this, I would get a TimeOut error. I am not sure why. According to the MSDN the HttpWebRequest.TimeOut default value is 100 seconds, but I get an error with-in 10.
Any clue how I can check for the sites availability if this is not the most accurate way or any idea why I can not get this code to execute correctly?
Thanks,
RalphTrent