3

In the past, I am used to using the customErrors element in the web.config to specify when to use a custom error page to hide detailed exception information from users.

From what I see now, it is preferred to use the httpErrors . I have referenced several different resources including the IIS documentation how to accomplish what I need, but I can't seem to figure it out. The requirements I need to specify in the web.config is the following:

1) If HTTP 404 Error
     a) If Local, just return IIS 404 or Yellow Screen of Death (YSOD) or whatever. (It doesn't really matter)
     b) If not local, execute URL /Path/To/My/404/ErrorMVCAction

2) If ANY OTHER HTTP ERROR
     a) Use static error.htm page.

Currently, we have the following:

<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
        <remove statusCode="404" />
        <error statusCode="404" 
               prefixLanguageFilePath="" 
               path="/Path/To/My/404/ErrorMVCAction" 
               responseMode="ExecuteURL" />
</httpErrors>

When I navigate to a page that doesn't exist and get a 404, I get my custom error page (I tested this by changing the errorMode to 'Custom'. However, when a 500 occurs, instead of getting the Yellow Screen of Death where I can see a stack trace locally, I get the Blue IIS Error Summary page. An example of this is shown below.

enter image description here

1 Answer 1

5

I had the same frustrating issue until I realised the httpErrors attribute existingResponse must be set to existingResponse="PassThrough". So try changing your configuration to this:

<httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough">
        <remove statusCode="404" />
        <error statusCode="404" 
               prefixLanguageFilePath="" 
               path="/Path/To/My/404/ErrorMVCAction" 
               responseMode="ExecuteURL" />
</httpErrors>

This certainly solved the equivalent annoying issue for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.