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

查看:18
本文介绍了如何将用户重定向到 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?

推荐答案

看一看 此页面 用于将您的 404 错误路由到指定页面.

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

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

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