title: ERR_CONNECTION_RESET: The connection was reset when uploading a large file
body: <p>I had a mysterious error where a file greater than 4MB generated a random error. Later on I realized it was caused due to the <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx" rel="noreferrer">http <code>maxrequestlength</code></a>
  . An image cannot be greater than 4MB when uploaded by default. </p>
  
  <p>I know that this can change from the web.config file.</p>
  
  <p>When I tried to cater for this error, by displaying another page, a different error started popping up. When debugging, the program enters application_error immediately.</p>
  
  <p>When executing <code>Server.GetLastError()</code> Exception generated:</p>
  
  <blockquote>
    <p>[System.Web.HttpUnhandledException] {"Exception of type
    'System.Web.HttpUnhandledException' was
    thrown."} System.Web.HttpUnhandledException</p>
    
    <p>the stack trace: at System.Web.UI.Page.HandleError(Exception e) at
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest() at
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at
    System.Web.UI.Page.ProcessRequest(HttpContext context) at
    ASP.businessprofile_aspx.ProcessRequest(HttpContext context) in
    c:\Users\Mattew\AppData\Local\Temp\Temporary ASP.NET
    Files\root\4ea30077\8f66786f\App_Web_h5fmhavk.4.cs:line 0 at
    System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    Boolean&amp; completedSynchronously)</p>
  </blockquote>
  
  <p>If I try any code inside the application_error method, e.g. redirecting, still the error page:
  Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
  is displayed. </p>
  
  <p>Questions</p>
  
  <ol>
  <li><p>How should this error be handled? Can it be handled before hand? So this error is not displayed? ( I tried using jquery to get the file size before and check it but I'm finding it too complex</p></li>
  <li><p>If Question 1 is not 'answerable', is there a way to intercept this error and display a friendly error?</p></li>
  </ol>