title: WebException: The underlying connection was closed
body: <p>I am currently calling a webservice from an ASP.net page.  I am trying to call a REST based web service to request a certain action and a 404 is returned (which represents a specific error for my application).  I try to catch the error but as a 404 is returned my application instead continues to hang and I end up catching the following error.</p>
  
  <p>[System.Net.WebException] = {"The underlying connection was closed: An unexpected error occurred on a receive."}</p>
  
  <p>Why would I catch a different error over 2 seconds after the web service responds with a 404?</p>
  
  <pre><code>try
  {
      newPassword = Customer.ResetPassword(_transaction.Centre.Id, newPassword);
  }
  catch(WebException ex)
  {
      HttpWebResponse response = (HttpWebResponse)ex.Response;
  
      if ((response != null) &amp;&amp; (response.StatusCode == HttpStatusCode.NotFound))
      {
          //then the email address doesnt exist
          ErrorPage(104);
      }
      else
      {
           ErrorPage();
      }
   }
   catch (Exception ex)
   {
      ErrorPage();
   }
  </code></pre>
  
  <p>and that calls this:</p>
  
  <pre><code>Request currentRequest = new Request(uri,
              Communication.Request.HttpRequestType.POST,[hidden][hidden]);
  
  Response response = currentRequest.Send(Serializer.Serialize&lt;ResetPassword (resetPassword));
  
  return Serializer.Deserialize&lt;ResetPassword&gt;(response.BodyData);
  </code></pre>
  
  <p>Please ignore the [hidden] tags.  Ive had to hide that from public view.  However, I hope that helps.</p>
  
  <p>Thank you all for your help!</p>