Turn IIS7 HTTP Error Handling Off?

Vance Lucas picture Vance Lucas · Feb 27, 2010 · Viewed 20.6k times · Source

I just got setup on my first Windows Server 2008 / IIS7.5 server for a contest I am participating in. I can't for the life of me figure out how to turn OFF error handling COMPLETELY. The only options I see are:

  • Custom
  • Detailed
  • Detailed Local, custom for remote

I want to turn the feature off completely, and I don't see any way to do that. Am I missing something?

My Situation:

I have a RESTful PHP framework that catches exceptions and emits an HTTP 500 status if the exception has not already been handled. It then puts the specified exception message in the response body and sends it to the browser. This works fine in Apache - the correct headers are sent and the message is displayed to the user. In IIS, however, the response for 4xx and 5xx HTTP status codes is always intercepted and injected with some other prepared message or HTML file, and that's exactly what I don't want it to do anymore. Please help!

Answer

Vance Lucas picture Vance Lucas · Feb 27, 2010

After some more extensive searching, I found the answer here:

http://blogs.msdn.com/webdevelopertips/archive/2009/08/24/tip-93-did-you-know-php-and-custom-error-pages-configuration.aspx

The solution is to manually edit your web.config file with this custom "httpErrors" entry:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors existingResponse="PassThrough" />
    </system.webServer>
</configuration>

However, due to IIS 7.0 "lockdown" feature you might get a "This configuration section cannot be used at this path. This happens when the section is locked at a parent level." error. To solve that, execute the following in the command prompt:

cd C:\Windows\System32\inetsrv

appcmd unlock config /section:httpErrors