Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there any way to prevent IIS from automatically overriding the output of a web app that is returning a status code in the 500 or 400 range?

Just as an example, in ColdFusion I can create the following page:

<cfheader statuscode="500" statustext="Error">
Sorry, an error occurred.

The behavior should be that I see a page that says "Sorry, an error occurred." and see in the headers that the status code is 500.

Instead, I see:

Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

In lovely IIS styling.

I tried just deleting the 500 custom status page but that simply resulted in:

The page cannot be displayed because an internal server error has occurred.

Without any of the lovely styling.

Looks like this happens with any page that returns a code that is not in the 200 or 300 range.

share|improve this question
add comment

3 Answers 3

There is apparently a way to do this using Response.TrySkipIisCustomErrors. The below example is from an aspx page but should be adaptable to your use case.

This following web content is too extensive to duplicate here.

http://www.west-wind.com/weblog/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors

share|improve this answer
1  
It looks like this is a change I make to the code I am writing, which will not work for two reasons: 1) I'm not writing a .net app, so I don't have access to something called Response.TrySkipIIsCustomErrors and 2) There's no way in hell I'm going to everywhere in my code that I return a status code other than 200 and rewrite it just to make IIS happy. –  Jordan Reiter Jun 7 '11 at 21:36
1  
Perhaps Cold Fusion offer a way then. Alternately, you could replace IIS pages with properly styled pages for your app. –  uSlackr Jun 7 '11 at 21:42
add comment
up vote 4 down vote accepted

This was answered in another question: IIS7 Hijacks My Coldfusion Error Page

Seems that the solution is changing the configuration so that IIS ignores the error and allows it to pass through, hence the setting

    <httpErrors existingResponse="PassThrough" />

So the solution is to change the behavior of IIS, which is fortunate, because requiring every existing web application server to change their behavior would be really stupid.

Update

Please see my updated answer in another similar question to find out why and how there is no workable answer to this problem.

share|improve this answer
add comment

Here's what definitely works: 1. Open Error pages for the web site or application 2. Click on Edit Feature Settings in the actions on the right 3. Select Detailed Errors and save

share|improve this answer
    
My understanding was that this would expose detailed error messages to all users. Is that not correct? –  Jordan Reiter Aug 2 '12 at 13:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.