title: Application_Error is not catching 404 type of error
body: <p>I'd like to catch these types of error globally so that I can log them to the database and display a nice message to the user: 500, 403, and 404. I'm using <strong>Log4Net</strong> to handle the error.</p>
  
  <pre><code>void Application_Error(object sender, EventArgs e)
  {      
    string redirectUrl = "~/Error/GenericError.aspx"; //I put a breakpoint here...
    var httpException = (HttpException)Server.GetLastError();
    int httpCode = httpException.GetHttpCode();
  
    //more code here...
  }
  </code></pre>
  
  <p>The breakpoint is being hit only when an exception happens, then the error is recognized as 500. </p>
  
  <p>However, when I misspell a <strong>URL</strong>, I except a 404 error to be caught by the <strong>Application_Error</strong> method. Instead, I the browser displays this page (see screenshot). There's no way to log the error in that case.</p>
  
  <p>I'm <strong>ASP.NET Webform 4.5</strong>. In the previous version, such as <strong>ASP.NET 4.0</strong>, I was able to catch all 3 types of errors.  </p>
  
  <p>Is there a way to catch the 404 error as well?</p>