如何显示自定义的404页的ASP.NET没有重定向? [英] How to show a custom 404 page in ASP.NET without redirect?

查看:93
本文介绍了如何显示自定义的404页的ASP.NET没有重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个请求是在ASP.NET 404在IIS 7我要显示自定义错误页。在地址栏的网址不应该改变,所以没有重定向。我怎样才能做到这一点?

When a request is 404 in ASP.NET on IIS 7 i want a custom error page to be displayed. The URL in the address bar should not change, so no redirect. How can i do this?

推荐答案

在应用程序的OnError事件可以为HttpExceptions测试与404状态code,然后做一个Server.Transfer的到自定义404页,代替的Response.Redirect。看一看 HTTP://blog.dmbcllc。 COM / 2009/03/02 / ASPNET-的Application_Error检测-404 /

In your application's OnError event you can test for HttpExceptions with a status code of 404, and then do a Server.Transfer to your custom 404 page, instead of a Response.Redirect. Have a look at http://blog.dmbcllc.com/2009/03/02/aspnet-application_error-detecting-404s/

这篇关于如何显示自定义的404页的ASP.NET没有重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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