title: HttpWebRequest NameResolutionFailure exception in .NET (with Mono on Ubuntu)
body: <p>I have a .NET program running on Ubuntu via Mono 2.10</p>
  
  <p>The program downloads a webpage via an HttpWebRequest every minute or so which works fine most of the time:</p>
  
  <pre><code>        String result;
          WebResponse objResponse;
          WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
  
          using (objResponse = objRequest.GetResponse())
          {
              using (StreamReader sr =
                 new StreamReader(objResponse.GetResponseStream()))
              {
                  result = sr.ReadToEnd();
                  // Close and clean up the StreamReader
                  sr.Close();
              }
          }
  </code></pre>
  
  <p>The problem is that after few days I start getting exceptions thrown:</p>
  
  <pre><code>        DateTime: 01/25/2012 08:15:41
          Type: System.Net.WebException
          Error: Error: NameResolutionFailure
          Stack:
            at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in &lt;filename unknown&gt;:0
            at System.Net.HttpWebRequest.GetResponse () [0x00000] in &lt;filename unknown&gt;:0
            at socks_server.Program.readHtmlPage (System.String url) [0x00000] in &lt;filename  unknown&gt;:0
            at socks_server.Program.getAccessKeysProc () [0x00000] in &lt;filename unknown&gt;:0
  </code></pre>
  
  <p>The server is still abel to resolve DNS, for example</p>
  
  <pre><code> wget http://www.google.com
  </code></pre>
  
  <p>Will return the file without any probelm as will ping and other commands that resolve DNS.</p>
  
  <p>My program however will continue to throw that exception until I restart it. After restarting the application it will start working again as it should.</p>
  
  <p>I have checked open file counts on the system (400 ish), memory usage (327mb of 4gb), CPU usage (2-3%) and all are OK.</p>
  
  <p>Any ideas?</p>