Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7.0 doesn't display custom error pages

I'm running an application that has its own error handlers. Error pages are displayed properly while testing in dev environment (error pages are displayed properly).
However the same code on the production IIS, error pages are substituted. The problem is described here.

I just wonder is there a way to write this settings in web.config file instead of modifying the code.

like image 981
Eugeniu Torica Avatar asked Aug 18 '09 09:08

Eugeniu Torica


People also ask

How do I enable detailed error messages in IIS 7?

To Enable detailed IIS Error messages:Open Internet Information Services (IIS) Manager. Select "Error Pages" Select "Edit Feature Settings" Select "Detailed Errors"

How do I enable custom errors in IIS?

You can add custom error messages to IIS by adding an <error> element to the <httpErrors> element in the Web. config file for your site, application, or URL.

How do I find a custom error page?

To display a custom error page with an appropriate error code, use the <httpErrors> section only, and do not use the <customErrors> section. Add the following <httpErrors> section under <system. webServer> section, as shown below.


2 Answers

Awe is right (+1), but in addition: IIS 7 has special handling described in the blog post you linked and this MSDN article. If you are using HandleErrorAttribute on your action, this is already done for you. If not, you'll need to set:

filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;

...yourself.

like image 65
Craig Stuntz Avatar answered Oct 09 '22 17:10

Craig Stuntz


Well It turned out that in order to force IIS 7 to show custom pages the following lines should be added to web.config file.

Put in system.webServer section

<httpErrors errorMode="Detailed"> <!-- this is impornant -->
<!-- Some custom error pages url go here -->
</httpErrors>
like image 38
Eugeniu Torica Avatar answered Oct 09 '22 16:10

Eugeniu Torica