URL 中的 ASP.NET aspxerrorpath

ASP.NET aspxerrorpath in URL(URL 中的 ASP.NET aspxerrorpath)

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

问题描述

我有一个网站,我在 web.config 中使用 CustomErrors 来指定自定义错误页面,这很好用.自定义 404 页面也在 IIS 配置中指定(因为如果没有,我就不会得到我的自定义 404 页面).

I have a site where I use CustomErrors in the web.config to specify a custom error page, and that's working just fine. The custom 404 page is also specified in the IIS configuration (because if it's not, I don't get my custom 404 page).

但是,如果用户收到一个 404,它会查看他们请求的 URL 并在适当的情况下提出导航建议,我有一些逻辑可以启动.此逻辑依赖于 aspxerrorpath 值.在我的开发 PC 上,aspxerrorpath 已正确附加到 URL,如下所示:http://localhost:3092/FileNotFound.aspx?aspxerrorpath=/badpage.aspx,但是在我的测试站点上,没有附加到 URL 的 aspxerrorpath,所以我的所有自定义逻辑都被绕过了,我的建议不起作用.我不确定这是 IIS 配置问题还是其他问题.Web 服务器是带有 IIS 7 的 Windows Server 2008.

But I have some logic that kicks in if a user gets a 404 that looks at their requested URL and make a navigation suggestion, if appropriate. This logic relies on the aspxerrorpath value. On my development PC, the aspxerrorpath is correctly appended to the URL, like so: http://localhost:3092/FileNotFound.aspx?aspxerrorpath=/badpage.aspx, but on my test site, there's no aspxerrorpath appended to the URL, so all of my custom logic is bypassed and my suggestions don't work. I'm not sure if this is an IIS config issue or something else. The web server is Windows Server 2008 with IIS 7.

有什么想法吗?

非常感谢.

推荐答案

如果错误被 .NET 捕获(并且使用 web.config 中指定的错误页面),则传递 aspxerrorpath 参数.如果您使用的是开发 Web 服务器,或者 IIS 配置为不检查文件是否存在,则会发生这种情况.

The aspxerrorpath parameter is passed if the error was caught by .NET (and the error page specified in web.config is used). This happens if you're using the development web server, or if IIS is configured not to check that the file exists.

如果 IIS 检查文件是否存在,则使用 IIS 中配置的自定义错误,并且请求的 URL 包含在查询字符串中,类似于

If IIS checks that the file exists, then the custom error configured in IIS is used, and the requested URL is included in the querystring as something like

http://example.com/FileNotFound.aspx?404;http://example.com/badpage.aspx

这篇关于URL 中的 ASP.NET aspxerrorpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:URL 中的 ASP.NET aspxerrorpath

基础教程推荐