ASP.NET 4.0错误处理除500状态外不起作用

时间:2016-05-09 02:38:45

标签: c#-4.0 error-handling webforms

我在项目中指定了自定义错误

<customErrors mode="On" defaultRedirect="http://redirect" />

它可以处理500错误状态,但是当我发出另一个错误时它不起作用 像http://127.0.0.1/home/1一样用于测试403或404错误得到很好的处理。

它不起作用。我的IIS服务器返回到IIS默认错误页面403或404如何处理此错误?

1 个答案:

答案 0 :(得分:0)

尝试使用以下格式:

<customErrors mode="On">
    <error code="403" path="403.html" />
    <error code="404" path="404.html" />
    <error code="500" path="500.html" />
</customErrors>

有关详细信息,请参阅MSDN here