title: How to handle 404 error in config and code in MVC5?
body: <p>I have implemented exception handling as mentioned in below link</p>
  
  <p><a href="https://stackoverflow.com/questions/39246370/how-to-pass-error-message-to-error-view-in-mvc-5/39248096#39248096">How to pass error message to error view in MVC 5?</a></p>
  
  <p>It is working fine. But I have requirement to handle <code>404 Error</code>.</p>
  
  <p>How can I do that?</p>
  
  <p>if I use below code, </p>
  
  <pre><code>&lt;customErrors mode="On"&gt;
    &lt;error statusCode="404" redirect="/Home/Error"&gt;&lt;/error&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>it works well when any <code>404</code> error occurs. But in case any other exception occurs then my <code>error.cshtml</code> call twice and show same exception <code>two times</code>.</p>