本文介绍了抛出ASP.NET 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是每个人的问题:



如果你要访问http://www.asp.net,你会得到一个漂亮的Default.aspx网页。



如果你去http://www.asp.net/NotFound.aspx,你会得到一个漂亮的ASP.NET 404页面找不到页面。 />


如果你去http://www.asp.net/NotFound,你会得到一个漂亮的IIS 404页面找不到页面。



如果你去http://www.asp.net/NotFound.txt,你会得到一个漂亮的IIS 404页面找不到页面。



如果网页(fake.aspx)将结果显示给经过身份验证的用户,但是您希望显示匿名的404页面,那该怎么办?



您可以为经过身份验证的用户设置Response.StatusCode = 200,并为匿名用户设置Response.StatusCode = 404。



这很有效,除了系统显示IIS 404页面未找到页面而不是未找到的ASP.NET 404页面。对于典型的访客,这不会是一个问题。他们看到404页面未找到并继续前进。但是,注意的人会注意到网页的显示方式有所不同。



以下是问题。



如何获得显示ASP的.ASPX页面。 NET 404页面找不到错误信息而不是IIS 404页面找不到页面?





感谢您的输入

解决方案



Here is a question for everyone:

If you to to http://www.asp.net, you get a pretty Default.aspx web-page.

If you go to http://www.asp.net/NotFound.aspx, you get a pretty ASP.NET 404 page not found page.

If you go to http://www.asp.net/NotFound, you get a pretty IIS 404 page not found page.

If you go to http://www.asp.net/NotFound.txt, you get a pretty IIS 404 page not found page.

What if webpage (fake.aspx) that would display it's results to an authenticated user, but you wanted to display the 404 page not found for the anonymous.

You could set the "Response.StatusCode = 200" for authenticated users and set the "Response.StatusCode = 404" for the anonymous users.

This works great, except the system displays the IIS 404 page not found page not the ASP.NET 404 page not found. For the typical visitor, this won't be a problem. They see a 404 page not found and move on. However, a person who is paying attention would notice there was a difference in how the webpage are displayed.

Here is the question.

How do you get an .ASPX page to show the ASP.NET 404 page not found error message instead of the IIS 404 page not found page?


Thanks for your input

解决方案



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

08-30 13:22