title: Catch block does not catch exception
body: <p>I have an action which should return an image if it was found on the server. If <code>filename</code> is valid, everything works as expected. But if the file was not found, it always throws an unhandled exception:</p>
  
  <blockquote>
    <p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</p>
  </blockquote>
  
  <p>Why is this exception not handled by the catch block?</p>
  
  <p>This is my simplified code:</p>
  
  <pre><code>public ActionResult Users(string filename)
      {
          try
          {
              var filePath = Server.MapPath("~/App_Data/uploads/users/" + filename);
              var file = File(filePath, "image/jpg", Path.GetFileName(filePath));
              return file;
          }
          catch
          {
              return Content("FILE NOT FOUND");
          }
      }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Could not find file 'C:\Projects\Extranet\App_Data\uploads\users\test123.png'.</p>
    
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.IO.FileNotFoundException: Could not find
    file 'C:\Projects\Extranet\App_Data\uploads\users\test123.png'.</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
  </blockquote>
  
  <p>Stacktrace:</p>
  
  <pre><code>[FileNotFoundException: Could not find file 'C:\Projects\Extranet\App_Data\uploads\users\test123.png'.]
     System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +9726591
     System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +1142
     System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +83
     System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length) +132
     System.Web.HttpResponseWrapper.TransmitFile(String filename) +20
     System.Web.Mvc.FilePathResult.WriteFile(HttpResponseBase response) +17
     System.Web.Mvc.FileResult.ExecuteResult(ControllerContext context) +188
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
     System.Web.Mvc.&lt;&gt;c__DisplayClass1c.&lt;InvokeActionResultWithFilters&gt;b__19() +23
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
     System.Web.Mvc.&lt;&gt;c__DisplayClass1e.&lt;InvokeActionResultWithFilters&gt;b__1b() +19
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
     System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
     System.Web.Mvc.Controller.ExecuteCore() +116
     System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
     System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
     System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +37
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +21
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +12
     System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
     System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +50
     System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7
     System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
     System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8967885
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184
  </code></pre>