如何将用户重定向到ASP.NET MVC中的自定义404页面,而不是抛出异常? [英] How do I redirect a user to a custom 404 page in ASP.NET MVC instead of throwing an exception?
本文介绍了如何将用户重定向到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
(应该是 / pages /
)。如何使它们被重定向到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?
推荐答案
看看< a href =http://richarddingwall.name/2008/08/09/three-common-aspnet-mvc-url-routing-issues/ =noreferrer>此页面用于路由您的404-指定页面的错误。
Take a look at this page for routing your 404-errors to a specified page.
这篇关于如何将用户重定向到ASP.NET MVC中的自定义404页面,而不是抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文