IIS Serves Custom Error page as plain text, no content-type header
asp.net-mvc-4, c#, error-handling, iis
Solution
Use .aspx instead of .htm for error pages (rename htm to aspx).
<customErrors mode="On" defaultRedirect="~/Content/Error.aspx" redirectMode="ResponseRewrite" />
Problem
UPD: Here is the full solution for error handling I've got plain vanilla MVC4 web-project. Nothing added, nothing deleted, just created a new project in Visual Studio. In `web.config` I've added custom error page handler: ``` <customErrors mode="On" defaultRedirect="~/Content/Error.htm" redirectMode="ResponseRewrite" /> ``` and the `~/Content/Error.htm` file is: ``` <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>OOPS! Error Occurred. Sorry about this.</title> </head> <body> <h2>OOPS! Error Occurred</h2> </body> </html> ``` Whenever I get a 404 error on the site, Error.htm is served as plaintext in Firefox and Chrome: Fiddler says that error page is served without `content-type` header which leads browsers to render the page as plain-text: Is there a way to force IIS server error pages with `content-type` header?? 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 dot at the end of the url. Solution with < httpErrors /> does serve correct responses, but our custom error handling in Global.asax, Application_Error() is not getting called this way. UPD 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: Facepalm!