title: Which HTTP Status Codes to cover for MVC error handling
body: <p>I'm currently developing custom error pages in my error handling code for my MVC application. But I'm unclear as to which HTTP status codes I'm meant to cover.</p>
  
  <p><strong>Question:</strong> is there a typical list of HTTP status codes that should be catered for?</p>
  
  <p>Alot articles which explain how to do MVC error handling and custom error pages but appear to only show several of the HTTP Status Codes: 403, 404, and 500 in their error handling code. What about HTTP Status Code: 408 as an example? Should this be covered? What about the tonne of other status codes -  <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes" rel="noreferrer">HTTP status codes on wiki</a></p>
  
  <p>This may sound like a dumb question, but I really don't know the answer and can't find an information on this. Am I missing something here, i.e. should only a subset of status codes be covered?</p>
  
  <p>If it helps, below is what I've done for my MVC error handling. This code (so far with the little testing that I've done) covers 404, and all 50x type exceptions:</p>
  
  <p><strong>1</strong> In web.config, and entry for each HTTP status code I want to cover</p>
  
  <pre><code>&lt;httpErrors errorMode="Custom" existingResponse="Replace" &gt;
    &lt;remove statusCode="403" /&gt;
    &lt;remove statusCode="404" /&gt;
    &lt;remove statusCode="500" /&gt;
    &lt;error statusCode="403" responseMode="ExecuteURL" path="/Error/Forbidden" /&gt;
    &lt;error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" /&gt;
    &lt;error statusCode="500" responseMode="ExecuteURL" path="/Error" /&gt;
  &lt;/httpErrors&gt;  
  </code></pre>
  
  <p><strong>2</strong> An error controller</p>
  
  <pre><code>    namespace MyApp.Controllers
      {
        public class ErrorController : Controller
        {
        public ActionResult Index()
        {
          return View();
        }
        public ActionResult Forbidden()
        {
          return View();
        }
        public ActionResult NotFound()
        {
          return View();
        }
  </code></pre>
  
  <p><strong>3</strong> User friendly error pages:</p>
  
  <pre><code>/Views/Shared/Index.cshtml
  /Views/Shared/Forbidden.cshtml
  /Views/Shared/NotFound.cshtml
  </code></pre>
  
  <p><strong>4</strong> ELMAH for logging</p>
  
  <p><strong>Further findings at 2 Nov 2015</strong></p>
  
  <p>Something I've just discovered that has been staring me in the face which I've missed... In IIS, the default Error pages covered are:</p>
  
  <ul>
  <li>401 – Unauthorized</li>
  <li>403 – Forbidden</li>
  <li>404 – Not Found</li>
  <li>405 – Method Not Allowed</li>
  <li>406 – Not Acceptable</li>
  <li>412 – Precondition Failed</li>
  <li>500 – Internal Server Error</li>
  <li>501 – Not Implemented</li>
  <li>502 – Bad Gateway</li>
  </ul>
  
  <p>If this is good range Microsoft have set, then I will go by this as a guide going forwards!</p>