title: IIS Serves Custom Error page as plain text, no content-type header
body: <p><strong>UPD</strong>: Here is the <a href="http://tech.trailmax.info/2013/08/error-handling-in-mvc-and-nice-error-pages/" rel="noreferrer">full solution for error handling</a></p>
  
  <p>I've got plain vanilla MVC4 web-project. Nothing added, nothing deleted, just created a new project in Visual Studio.</p>
  
  <p>In <code>web.config</code> I've added custom error page handler:</p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/Content/Error.htm" redirectMode="ResponseRewrite" /&gt;
  </code></pre>
  
  <p>and the <code>~/Content/Error.htm</code> file is:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;OOPS! Error Occurred. Sorry about this.&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h2&gt;OOPS! Error Occurred&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Whenever I get a 404 error on the site, Error.htm is served as plaintext in Firefox and Chrome:</p>
  
  <p><img src="https://i.stack.imgur.com/8oNLe.png" alt="HTML is displayed as plain text"></p>
  
  <p>Fiddler says that error page is served without <code>content-type</code> header which leads browsers to render the page as plain-text:</p>
  
  <p><img src="https://i.stack.imgur.com/EFoEg.png" alt="No Content-type header"></p>
  
  <p><strong>Is there a way to force IIS server error pages with <code>content-type</code> header??</strong></p>
  
  <p>p.s. the actual problem is in a complex MVC4 project, that has it's own error handling in Global.asax. But I found that some errors don't go through the ASP pipe and handled only by IIS. Like <a href="https://stackoverflow.com/questions/429963/the-resource-cannot-be-found-error-when-there-is-a-dot-at-the-end-of-the-ur">dot at the end of the url</a>. Solution with <a href="https://stackoverflow.com/a/6661699/809357">&lt; httpErrors /></a> does serve correct responses, but our custom error handling in Global.asax, Application_Error() is not getting called this way.</p>
  
  <p><strong>UPD</strong> Seems like I can't win this war. IE displays that html properly rendered, Firefox and Chrome shows as plain text. When I switch to plain-text, Firefox and IE shows white-space correctly, IE swallows white-space and tries to render html. If I try serve an image as error page, Firefox and Chrome show image. IE shows this: 
  <img src="https://i.stack.imgur.com/FXS4l.png" alt="IE9 is on crack!">
  Facepalm!</p>