title: MVC Custom errors not working in IIS8.5 (but working locally)
body: <p>I can't get ANY custom error pages to appear in IIS8.5!</p>
  
  <p>When I run my MVC 5 app locally in Visual Studio, custom error pages are displayed. But when I deploy to IIS on my webserver, and navigate to the site sub-page with a 'bad URL' my custom 404 page should be displayed, but the default generic 404 page is shown instead.</p>
  
  <p>Here is what I've done:</p>
  
  <p><strong>web.config</strong></p>
  
  <p>customError section has been deleted.</p>
  
  <p>Added the following section</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;httpErrors errorMode="Custom" existingResponse="Replace"&gt;
        &lt;remove statusCode="404" /&gt;
        &lt;remove statusCode="500" /&gt;
        &lt;error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" /&gt;      
        &lt;error statusCode="500" responseMode="ExecuteURL" path="/Error/ServerError" /&gt;      
      &lt;/httpErrors&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>namespace MyApp.Controllers
  {
    [Authorize(Roles = "MyRole")]
    public class ErrorController : Controller
    {
      [AllowAnonymous]
      public ActionResult NotFound()
      {
          Response.StatusCode = 404;
  
          return View();
      }
  
      [AllowAnonymous]
      public ActionResult ServerError()
      {
          Response.StatusCode = 500;
  
          return View();
      }
    }
  }
  </code></pre>
  
  <p><strong>Views</strong></p>
  
  <p>Very simple and straight forwards (not included here).</p>
  
  <p><strong>IIS</strong></p>
  
  <p>Verified the IIS Error Page feature is identical to what's in my config. A page for each error status code. Feature and Pages are set to 'custom'.</p>
  
  <p>Checked Windows Features\Web Server (IIS)\Web Server\Common HTTP Features\HTTP Errors is installed.</p>
  
  <p><strong>Developer Tools</strong></p>
  
  <p>Navigating to a sub-page spelt incorrectly shows I'm getting a 404 Client Error.</p>
  
  <p><strong>Help</strong></p>
  
  <p>I've tries many things! Am I missing something? IIS environmental issue, i.e. a setting somewhere?</p>
  
  <p>Custom errors work in my IDE but not on IIS. I've spent over a day on this! Read many pages, articles, and similar questions on SO.</p>