问题描述
我在 ASP.NET 网站上设置了自定义错误页面.
I have custom error pages setup on an ASP.NET website.
有一个错误没有显示自定义错误页面,而只是显示了通常的黄色 ASP.NET 错误页面.如果打开自定义错误,则会显示/应用程序中的服务器错误"/运行时错误",但如果关闭自定义错误,则会显示viewstate mac 验证失败"错误.
There is one error that is not showing a custom error page, and just showing the usual yellow ASP.NET error page. If custom errors are turned on it shows "Server error in / application" / "Runtime error", but if custom errors are off it shows "validation of viewstate mac failed" error.
我的 web.config 的相关部分是:
The relevant parts of my web.config are:
<system.web>
<compilation debug="false" targetFramework="4.0" />
<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="/404.aspx" />
<error statusCode="500" redirect="/500.aspx" />
</customErrors>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" />
要捕获此错误,我是否必须使用不同的状态代码或子状态代码,或者还有其他什么?
To trap for this error do I have to use a different status code or substatuscode or is there something else?
注意.服务器 2008 R2,IIS 7.
NB. Server 2008 R2, IIS 7.
推荐答案
经过进一步研究,我发现这意味着 IIS 正在显示错误,而不是 ASP.NET.
After further research I see that this means that IIS is displaying the error rather than ASP.NET.
我更改了 web.config 的 system.webServer 部分,因此 IIS 也可以使用自定义错误页面,从而解决了问题.
I changed the system.webServer part of my web.config so IIS can also use the custom error page and that has solved the problem.
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" subStatusCode="-1" responseMode="ExecuteURL" path="/500.aspx" />
</httpErrors>
这篇关于IIS 自定义错误未显示自定义错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!