title: Custom error pages in ASP.NET MVC 5
body: <p>I want to add custom error pages to my project. 
  I found <a href="http://benfoster.io/blog/aspnet-mvc-custom-error-pages" rel="nofollow">this post about my problem</a> and i try to implement it. </p>
  
  <p>So :</p>
  
  <ul>
  <li>i add <code>404.cshtml</code>, <code>404.html</code>, <code>500.cshtml</code> and <code>500.html</code> pages</li>
  <li>set response status code in added cshtml files</li>
  <li>comment adding <code>HandleErrorAttribute</code> to global filters</li>
  <li>update my web.config file</li>
  </ul>
  
  <p>But now when i try to go by path <code>http://localhost:120/foo/bar</code> where my app is on <code>http://localhost:120</code> i get next page :</p>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>Runtime Error</p>
    
    <p>Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated. </p>
  </blockquote>
  
  <p>I set <code>&lt;customErrors mode="Off"</code> to see what problem is. It was - <code>The resource cannot be found.</code> which is logical. But when i set <code>&lt;customErrors mode="On"</code> - i again get Runtime error. </p>
  
  <p>What can cause it and how to solve it? </p>
  
  <hr>
  
  <p>My config file :</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;customErrors mode="Off" redirectMode="ResponseRewrite" defaultRedirect="~/500.cshtml"&gt;
          &lt;error statusCode="404" redirect="~/404.cshtml"/&gt;
          &lt;error statusCode="500" redirect="~/500.cshtml"/&gt;
      &lt;/customErrors&gt;
  &lt;/system.web&gt;
  
  &lt;system.webServer&gt;
      &lt;httpErrors errorMode="Custom"&gt;
          &lt;remove statusCode="404"/&gt;
          &lt;error statusCode="404" path="404.html" responseMode="File"/&gt;
          &lt;remove statusCode="500"/&gt;
          &lt;error statusCode="500" path="500.html" responseMode="File"/&gt;
      &lt;/httpErrors&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <hr>
  
  <p>IIS version 8.5</p>