开发者

Turn IIS7 HTTP Error Handling Off?

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 开发者_Go百科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!


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


In IIS Manager -> Site -> Error Pages, right-click each error page and choose ‘Remove’.

Unfortunately there is not a way to tell IIS not to interfere from the script side, so it's always an annoying deployment issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜