title: Compact Framework - WebRequest sometimes fails for no reason?
body: <p>I've got a web service that I talk to from a PDA. In the same directory as the webservice asmx file, I have an html file that I pull a web request from in order to see if the directory is available.</p>
  
  <p>I use the following code:</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Holds the web request for checking the connectivity.
      /// &lt;/summary&gt;
      private static WebRequest m_WebRequest;
  
  
      /// &lt;summary&gt;
      /// Tests the connection to the provided URL.
      /// &lt;/summary&gt;
      /// &lt;param name="url"&gt;The URL to test.&lt;/param&gt;
      /// &lt;returns&gt;True if the URL was resolved.&lt;/returns&gt;
      public static bool TestUrl(string url)
      {
  
          try
          {
  
  
              // Ensure the url is valid
              url = url.Replace("http:\\", "http://");
              url = url.Replace("\\", "/");
  
              // Create the request
              m_WebRequest = WebRequest.Create(url);
              m_WebRequest.Timeout = 30000;
  
              // Get the request
              HttpWebResponse response = (HttpWebResponse)m_WebRequest.GetResponse();
              return true;
  
          }
          catch
          {
              m_WebRequest.Abort();
              return false;
          }
  
      }
  </code></pre>
  
  <p>The file I am getting the response for is always the same and is always accessible from my PC. It only seems to fail when the web service (in the same directory as the html file) errors. Could that be related?</p>
  
  <p>Alternatively, is there a better way of seeing if that file exists over the web?</p>