为 5xx 和 4xx HTTP 状态代码禁用 IIS 7.5 服务器错误响应

Jor*_*ter 4 iis custom-errors http-status-code

有什么方法可以防止 IIS 自动覆盖返回 500 或 400 范围内的状态代码的 Web 应用程序的输出?

举个例子,在 ColdFusion 中,我可以创建以下页面:

<cfheader statuscode="500" statustext="Error">
Sorry, an error occurred.
Run Code Online (Sandbox Code Playgroud)

行为应该是我看到一个页面,上面写着“对不起,发生了错误”。并在标题中看到状态代码为 500。

相反,我看到:

Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Run Code Online (Sandbox Code Playgroud)

在可爱的 IIS 样式中。

我尝试删除 500 个自定义状态页面,但这只是导致:

The page cannot be displayed because an internal server error has occurred.
Run Code Online (Sandbox Code Playgroud)

没有任何可爱的造型。

看起来这种情况发生在任何返回不在 200 或 300 范围内的代码的页面上。

Jor*_*ter 7

这是在另一个问题中回答的: IIS7 Hijacks My Coldfusion Error Page

似乎解决方案正在更改配置,以便 IIS 忽略错误并允许它通过,因此设置

    <httpErrors existingResponse="PassThrough" />
Run Code Online (Sandbox Code Playgroud)

所以解决方案是改变IIS的行为,这是幸运的,因为要求每个现有的Web应用服务器改变它们的行为是非常愚蠢的。

更新

请参阅我在另一个类似问题中的更新答案,以了解此问题没有可行答案的原因和方式。