In my WPF application, I need to check the availability of a website at regular interval.
I have this code :
public static string CheckWebsiteAccessibility(Uri uri)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Timeout = 15000;
request.Method = "HEAD";
var response = (HttpWebResponse)request.GetResponse();
return response.StatusCode.ToString();
}
That I call every 30 seconds. In localhost it's working, but on another server I sometimes get the error :
The operation has timed out
Is this a good web to check the website availability ?
What can be the reason of the TimeOut (firewall?) and how can I avoid it ?