title: C# - Testing Internet page - Waiting for timeout
body: <p>To test if our computer is connected to a firewall we check if the loginwebpage for this firewall opens. If it times out, the error handling will say it's connected, if it opens (or throws a certificate error as it does in our case) we know we are not connected. </p>
  
  <p>The big problem with this process is that whenever we are already connected, the application hangs until the webpage times out.. </p>
  
  <p>Any input is more than welcome, here's the code I use:</p>
  
  <pre><code>    public static bool FirewallConnectivityStatus(string url)
      {
          try
          {
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
              request.Proxy = null;
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
              if (HttpStatusCode.OK == response.StatusCode)
              {
                  response.Close();
                  return false;
              }
              else
              {
                  return true;
              }
  
  
          }
          catch (WebException Ex)
          {
              if (Ex.Status == WebExceptionStatus.TrustFailure)
              {
                  return false;
              }
              else
              {
                  return true;
              }
          }
  
      }
  </code></pre>
  
  <p><strong><em>Update</em></strong>
  In the meantime I have found a socket connection that will allow me far better to create this connection via the IP in stead of the url: <a href="https://stackoverflow.com/questions/8115864/c-sharp-socket-to-log-on-to-firewall">C# - Socket to log on to Firewall</a></p>