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

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

推荐答案

另一种解决方案.

向带有 404 错误信息的 ErrorControllers 或静态页面添加.

Add ErrorControllers or static page to with 404 error information.

修改您的 web.config(如果是控制器).

Modify your web.config (in case of controller).

<system.web>
    <customErrors mode="On" >
       <error statusCode="404" redirect="~/Errors/Error404" />
    </customErrors>
</system.web>

或者在静态页面的情况下

Or in case of static page

<system.web>
    <customErrors mode="On" >
        <error statusCode="404" redirect="~/Static404.html" />
    </customErrors>
</system.web>

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

This will handle both missed routes and missed actions.

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

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