哪里&LT;&的customErrors GT;在web.config中去MVC应用? [英] Where does <customErrors> in web.config go for MVC applications?
本文介绍了哪里&LT;&的customErrors GT;在web.config中去MVC应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图实现我的MVC应用程序4自定义错误处理。我不能确定在哪里我的web.config中的&LT;的customErrors方式&gt;
应该去,和一般的信息,我需要在其中包括
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.
推荐答案
&LT;的customErrors&GT;
走了进去&LT;的System.Web&GT;
:
<configuration>
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="500"
redirect="~/Error/InternalServer" />
<error statusCode="404"
redirect="~/Error/NotFound" />
</customErrors>
</system.web>
</configuration>
修改的值重定向
根据你的路由属性。您还可以实现一个包罗万象的重定向通过增加一个的defaultRedirect
属性添加到的customErrors
元素。请参见这个MSDN文章了解详情。
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.
这篇关于哪里&LT;&的customErrors GT;在web.config中去MVC应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文