title: How to have a custom 404 and 500 error pages with a stock standard ASP.NET MVC3 website?
body: <p>I'm trying to have 2 custom error pages in a stock sample ASP.NET MVC3 website.</p>
  
  <p><a href="https://stackoverflow.com/questions/5226791/custom-error-pages-on-asp-net-mvc3">Darin Dimitrov has a good SO answer here</a> but it's not working for all my test conditions.</p>
  
  <p>Then there is the widely popular <a href="https://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc/620559#620559">How can I properly handle 404s in ASP.NET MVC?</a> post .. but this just touches on a 404 error.</p>
  
  <p>Can someone please explain what </p>
  
  <ul>
  <li>Routes</li>
  <li><code>web.config</code> settings</li>
  <li>controllers / action methods</li>
  </ul>
  
  <p>are required to do this very simple thing :(</p>
  
  <p>Scenarios to accept this answer:</p>
  
  <ul>
  <li>VS2010 -> File -> New -> ASP.NET MVC3 project / Internet Application</li>
  <li>(Right Click on the solution).. -> Use IIS Express</li>
  <li>Error pages cannot be a static html page. They must be a page which I can pass info to, like any other view, etc. (eg. an <code>ErrorController</code>)...</li>
  </ul>
  
  <p>and for the test routes... </p>
  
  <ul>
  <li><code>/Home/Index</code> -> shows index page</li>
  <li><code>/Home</code> -> shows index page</li>
  <li><code>/</code> -> shows index page</li>
  <li><code>/Home/About</code> -> shows about page</li>
  <li><code>/asdasd/asdsad/asdas/asddasd/adsad</code> -> 404</li>
  <li><code>/adsa/asda/asd/asd/asd/asd</code> -> 404</li>
  <li><code>/asdsadasda</code> -> 404</li>
  </ul>
  
  <p>then add this to the <code>HomeController.cs</code> class..</p>
  
  <pre><code>public ActionResult ThrowException()
  {
      throw new NotImplementedException();
  }
  </code></pre>
  
  <p>and now ..</p>
  
  <ul>
  <li><code>/home/throwexception</code> -> 500 error</li>
  </ul>
  
  <p>Cheers :)</p>
  
  <p>BTW, some of those realy long routes (above) give really weird error pages right now, when using the stock standard <code>new ASP.NET MVC3</code> template </p>