title: Unable to catch 403 error in Application_Error
body: <p>I have asp.net mvc 4 site hosted in IIS 7.5. I'm handling all the http errors manually in the Application_Error handler. Everything is fine except the 403 error(for example when navigating to the <code>http://mysite/App_Data</code>). The problem is that the Application_Error doesn't catch this error. Could someone tell me how to get it working?  </p>
  
  <p>EDIT</p>
  
  <p>I found out that the Application_Error catches only exceptions thrown in the managed modules. Since 403 error (in my case it's 403.14) is thrown by the DirectoryListingModule which is unmanaged, this error cannot be caught by the Application_Error. Also, it might be 404.7 or 404.8 errors handled by the RequestFilteringModule(also unmanaged). The only way I found to customize the handling of these errors is to use the following settings:</p>
  
  <pre><code>  &lt;httpErrors errorMode="Custom" existingResponse="Replace"&gt;
        &lt;error path="/Error/Forbidden" statusCode="403" subStatusCode="14" responseMode="ExecuteURL"/&gt;
        &lt;error path="/Error/NotFound" statusCode="404" subStatusCode="7" responseMode="ExecuteURL"/&gt;
        &lt;error path="/Error/NotFound" statusCode="404" subStatusCode="8" responseMode="ExecuteURL"/&gt;
    &lt;/httpErrors&gt;
  </code></pre>
  
  <p>having the ErrorController with the NotFound action. But there is one drawback with this approach for me - the original request data that causes the error is lost(because a child server-side redirect is performed) and I have no way to get it(at least I don't know how).
  So, now I'd like to change my question: Is it the only way to handle such errors ? And are there ways to get the original request data when using the httpErrors approach? </p>