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

查看:137
本文介绍了ASP.NET MVC 404错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:


我已经在 404 Asp.Net MVC(RC 5)中的Http错误处理程序,我仍然收到标准的404错误页面。我需要在IIS中更改某些内容吗?

解决方案

另一种解决方案。



修改您的web.config(在控制器的情况下)。

 < customErrors mode =On> 
< error statusCode =404redirect =〜/ Errors / Error404/>
< / customErrors>

或静态页面

 < customErrors mode =On> 
< error statusCode =404redirect =〜/ Static404.html/>
< / customErrors>

这将处理错过的路线和错过的动作。


Possible Duplicate:
How can I properly handle 404 in ASP.NET MVC?

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?

解决方案

Yet another solution.

Add ErrorControllers or static page to with 404 error information.

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天全站免登陆