title: try catch on ExecutionTimeout not working
body: <p>This one has been the source of much torment for me! I am using the global <code>ExecutionTimeout</code> of 110 seconds for my application. One particular page generates a great number of unhandled exceptions as it contains a <code>FileUpload</code> control.</p>
  
  <p>Now here is the problem...I know how to limit the file size and the execution timeout in the web.config using the following declarations.</p>
  
  <pre><code>&lt;httpRuntime maxRequestLength="2097152" executionTimeout="600" /&gt;
  </code></pre>
  
  <p>The problem I have is right here:</p>
  
  <pre><code>    'Check file size
      Dim fileSize As Integer
      Try
          fileSize = FileUpload1.FileBytes.Length
      Catch ex As Exception
          'Display message to user...
          Exit Sub
      End Try
  </code></pre>
  
  <p>The very process of checking the file length quite frequently throws an exception, and that exception isn't caught gracefully in the above <code>try, catch</code>, it seems to defer to the application level exception handling in the global.asax.</p>
  
  <p>I'm pretty sure I can't check the file size on the client-side, I don't want to keep bumping up the <code>maxRequestLength</code> and <code>executionTimeout</code>, all I'm looking to do is catch those timeouts on the page and display a message. Is this possible?</p>
  
  <p><strong>EDIT ---</strong></p>
  
  <p>To better illustrate the problem here, try running the following code (assumes your default executionTimeout is 110 seconds).</p>
  
  <pre><code>    Try
          system.threading.thread.sleep(120000)
      Catch ex As Exception
          response.write("Error caught!!")
          Exit Sub
      End Try
  </code></pre>
  
  <p>Make sure debug is switched off. The catch block won't work and you'll end up with an unhandled <code>System.Web.HttpException: Request timed out</code> error, this I have yet to figure out?</p>