ASP.NET MVC的404错误处理 [英] ASP.NET MVC 404 Error Handling

查看:88
本文介绍了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.

这篇关于ASP.NET MVC的404错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆