20
我试图在我的MVC 4应用程序中实现自定义错误处理。我不确定在我的web.config文件中应该包含<customErrors>
的位置以及我需要包含的一般信息。web.config中的<customErrors>在哪里用于MVC应用程序?
我试图在我的MVC 4应用程序中实现自定义错误处理。我不确定在我的web.config文件中应该包含<customErrors>
的位置以及我需要包含的一般信息。web.config中的<customErrors>在哪里用于MVC应用程序?
<customErrors>
走了进去<system.web>
:根据您的路线redirect
属性
<configuration>
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="500"
redirect="~/Error/InternalServer" />
<error statusCode="404"
redirect="~/Error/NotFound" />
</customErrors>
</system.web>
</configuration>
修改值。您还可以通过向customErrors
元素添加defaultRedirect
属性来实现全面重定向。有关更多信息,请参阅this MSDN article。