windows 关闭 IIS7 HTTP 错误处理?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2345532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Turn IIS7 HTTP Error Handling Off?
提问by Vance Lucas
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:
我刚刚在我参加的比赛中在我的第一个 Windows Server 2008 / IIS7.5 服务器上进行了设置。我一生都无法弄清楚如何完全关闭错误处理。我看到的唯一选项是:
- 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!
我有一个 RESTful PHP 框架,它可以捕获异常并在尚未处理异常时发出 HTTP 500 状态。然后它将指定的异常消息放入响应正文并将其发送到浏览器。这在 Apache 中工作正常 - 发送正确的标头并向用户显示消息。然而,在 IIS 中,4xx 和 5xx HTTP 状态代码的响应总是被拦截并注入一些其他准备好的消息或 HTML 文件,这正是我不希望它再做的事情。请帮忙!
回答by Vance Lucas
After some more extensive searching, I found the answer here:
经过更广泛的搜索,我在这里找到了答案:
The solution is to manually edit your web.configfile with this custom "httpErrors" entry:
解决方案是使用此自定义“httpErrors”条目手动编辑您的web.config文件:
<?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:
但是,由于 IIS 7.0 的“锁定”功能,您可能会收到“无法在此路径上使用此配置部分。当该部分在父级别锁定时会发生这种情况。” 错误。要解决该问题,请在命令提示符中执行以下操作:
cd C:\Windows\System32\inetsrv
appcmd unlock config /section:httpErrors
回答by bobince
In IIS Manager -> Site -> Error Pages, right-click each error page and choose ‘Remove'.
在 IIS 管理器 -> 站点 -> 错误页面中,右键单击每个错误页面并选择“删除”。
Unfortunately there is not a way to tell IIS not to interfere from the script side, so it's always an annoying deployment issue.
不幸的是,没有办法告诉 IIS 不要从脚本端进行干扰,因此它始终是一个烦人的部署问题。