如何在ASP.NET MVC将用户重定向到自定义404页,而不是抛出异常? [英] How do I redirect a user to a custom 404 page in ASP.NET MVC instead of throwing an exception?

查看:88
本文介绍了如何在ASP.NET MVC将用户重定向到自定义404页,而不是抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够捕捉到所引发的异常当用户请求一个不存在的控制器,它重新导向至404页。我怎样才能做到这一点?

I want to be able to capture the exception that is thrown when a user requests a non-existent controller and re-direct it to a 404 page. How can I do this?

例如,用户请求 http://www.nosite.com/paeges/1 /页/ )。我该如何使它所以他们得到重新定向到404,而不是例外屏?

For example, the user requests http://www.nosite.com/paeges/1 (should be /pages/). How do I make it so they get re-directed to the 404 rather than the exception screen?

推荐答案

看看的此页面路由404-错误到指定的页面。

Take a look at this page for routing your 404-errors to a specified page.

这篇关于如何在ASP.NET MVC将用户重定向到自定义404页,而不是抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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