I'm attempting to implement custom error handling in my MVC 4 app. I'm not certain where in my web.config the <customErrors>
is supposed to go, and the general information I need to include in it.
我正在尝试在我的MVC 4应用程序中实现自定义错误处理。我不确定我的web.config中的
1 个解决方案
#1
29
<customErrors>
goes inside <system.web>
:
<configuration>
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="500"
redirect="~/Error/InternalServer" />
<error statusCode="404"
redirect="~/Error/NotFound" />
</customErrors>
</system.web>
</configuration>
Modify values of the redirect
attributes according to your routes. You can also implement a catch-all redirect by adding a defaultRedirect
attribute to the customErrors
element. See this MSDN article for more information.
根据您的路由修改重定向属性的值。您还可以通过向customErrors元素添加defaultRedirect属性来实现catch-all重定向。有关更多信息,请参阅此MSDN文章。
#1
29
<customErrors>
goes inside <system.web>
:
<configuration>
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="500"
redirect="~/Error/InternalServer" />
<error statusCode="404"
redirect="~/Error/NotFound" />
</customErrors>
</system.web>
</configuration>
Modify values of the redirect
attributes according to your routes. You can also implement a catch-all redirect by adding a defaultRedirect
attribute to the customErrors
element. See this MSDN article for more information.
根据您的路由修改重定向属性的值。您还可以通过向customErrors元素添加defaultRedirect属性来实现catch-all重定向。有关更多信息,请参阅此MSDN文章。