views:

907

answers:

3

I running an application that have a proper error handlers. When testing in dev environment all works fine, error pages are displayed properly.
However when moving the same code to the production IIS is catching error pages and substitutes them with its own. 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.

+1  A: 

There is a setting in the applications Web.config file to set the debug mode:

Default is:

<customErrors mode="RemoteOnly" />

Try setting it to "Off" (Note: the value is case sensitive!)

<customErrors mode="Off" />

I'm not sure if this setting is respected by IIS7, but since you see different behaviour on your development environment from the deployed, this was my fist guess. To test if this is the case, you can try to run your dev app from a different machine in your network if you have that possibility.

awe
I have tried but it didn't work. I also included some server settings in .config file but it turned out that IIS somehow ignores them.
Jenea
+1  A: 

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.

Craig Stuntz
What was the reason for this setting?
Jenea
Obviously, I don't speak for Microsoft. I can only guess at their motivations. My wild guess is that users consider real error messages to be "scary." Hence, the fake error pages in IE, and this feature. Hence, probably, the pages you're displaying in your MVC application. You just need to tell IIS that you've already supplied a user-friendly error message, so it doesn't need to bother.
Craig Stuntz
+1  A: 

Well It turned out that in order to force IIS 7 to show custom pages in web.config file in system.webServer section should be placed

<httpErrors errorMode="Detailed"> <!-- this is impornant -->
<!-- Some custom error pages url go here -->
</httpErrors>
Jenea