ASP.NET MVC的404错误处理
问题描述:
可能重复:结果
如何正确我在ASP.NET MVC处理404?
我做的 404 HTTP错误列出的变化处理程序Asp.Net MVC(RC 5),我仍然得到标准的404错误页面。我需要改变的东西在IIS中?
I've made the changes outlined at 404 Http error handler in Asp.Net MVC (RC 5) and I'm still getting the standard 404 error page. Do I need to change something in IIS?
答
又一解决方案。
添加ErrorControllers或静态页面与404错误信息。
Add ErrorControllers or static page to with 404 error information.
修改你的web.config(在控制器的情况下)。
Modify you web.config (in case of controller).
<customErrors mode="On" >
<error statusCode="404" redirect="~/Errors/Error404" />
</customErrors>
还是在静态页面的情况下
Or in case of static page
<customErrors mode="On" >
<error statusCode="404" redirect="~/Static404.html" />
</customErrors>
这将同时处理错过的路线,错过的行动。
This will handle both missed routes and missed actions.