title: Check website availability in c#
body: <p>In my WPF application, I need to check the availability of a website at regular interval.</p>
  
  <p>I have this code :</p>
  
  <pre><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();
  }
  </code></pre>
  
  <p>That I call every 30 seconds. In localhost it's working, but on another server I sometimes get the error :</p>
  
  <blockquote>
    <p>The operation has timed out</p>
  </blockquote>
  
  <ol>
  <li><p>Is this a good web to check the website availability ?</p></li>
  <li><p>What can be the reason of the TimeOut (firewall?) and how can I avoid it ?</p></li>
  </ol>