title: Definitive Guide to Handling 500 Errors in IIS6, IIS7, ASP.NET MVC3 with Custom Page
body: <p>I'm trying to add a 500 error handling page to my ASP.NET MVC3 project.</p>
  
  <p>I want my custom error page displayed regardless of local or remote access.
  My website is running on IIS6,IIS7 &amp; IIS7.5 Express</p>
  
  <p>I want it displayed when:</p>
  
  <ul>
  <li>An exception is thrown in Application_BeginRequest</li>
  <li>An exception is thrown in Application_Error</li>
  <li>An exception is thrown in a static constructor in the Website Project</li>
  <li>An exception is thrown in a Controller</li>
  <li>An exception is thrown in a view</li>
  <li>An exception thrown anywhere pretty much.</li>
  </ul>
  
  <p>I haven't been able to do in this, in fact I haven't been able to get any custom error pages to display at all.</p>
  
  <p>My error page lives in <code>~/Views/Shared/Error.aspx</code></p>
  
  <p>My Application_Error method in Global.asax.cs just logs the thrown exception.</p>
  
  <p>My web.config has this:</p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/Views/Shared/Error.aspx" redirectMode="ResponseRewrite"&gt;
  &lt;/customErrors&gt;
  ...
  &lt;system.webServer&gt;
    &lt;httpErrors errorMode="Custom" /&gt;
    ...
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>What am I missing? What do I need to do to handle these scenarios?</p>