【发布时间】:2015-12-28 20:52:48
【问题描述】:
我正在开发一个在 IIS 8.5 上运行的(Web 窗体)站点,目前正在为 404 和 500 设置错误处理。
我已经有了system.web > customErrors 设置,但是由于我们在集成模式/更新版本的 IIS 下运行,它从system.webServer > httpErrors 中提取。
使用 IIS GUI,我选择在网站上用静态 HTML 文件替换标准 IIS 错误页面:
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath=""
path="/problem.html" responseMode="ExecuteURL" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" prefixLanguageFilePath=""
path="/problem.html" responseMode="ExecuteURL" />
</httpErrors>
不幸的是,当显示正确的错误页面时,不是返回 404,而是返回 200,对于 500 错误,返回 302 后跟 200。
对于旧版本的 IIS,或未在集成模式下运行的 IIS,您可以在 customErrors 元素上设置 redirectMode="ResponseRewrite",这将解决此问题。
我尝试将httpErrors 上的existingResponse 设置为所有三个可用选项,并尝试更新设置responseMode="File",但这些都没有改变。
有没有办法为httpErrrors element 做类似的事情?还是我坚持将错误指向 ASP.NET 页面并从那里返回适当的错误?
谢谢!
【问题讨论】:
标签: asp.net iis-8.5 custom-errors integrated-pipeline-mode