问题描述
我们运行一个链接重定向服务,它可以处理各种格式的链接.其中一种格式是将目标 URL 附加到链接的末尾,例如
We run a link redirection service which can handle links thrown at it in various formats. One of these formats is to append the destination URL to the end of the link, for example
http://url.fwd/abcd/http://www.mydomain.com/page.aspx
过去两年这一直在 Windows Server 2003/IIS6 机器上运行,但现在我们正试图转移到 Windows Server 2008/IIS7 设置,但它不再工作了.
This was working on a Windows Server 2003 / IIS6 box for the last two years, but now we're trying to move to a Windows Server 2008 / IIS7 setup and its not working anymore.
我已经阅读了有关 URL 中冒号的问题,但它不会影响不以.aspx"结尾的页面.例如,
I've read about the problem with colons in the URL but it doesn't affect pages not ending in '.aspx'. For instance,
http://url.fwd/abcd/http://www.mydomain.com/page.php
会很好地重定向.
http://url.fwd/abcd/http//www.mydomain.com/page.aspx
也可以正常工作(注意缺少第二个冒号).尽管是错误的 URL,但它确实由我们的 URL 转发系统处理,该系统使用自定义 404 页面.在旧系统上,我们遇到了类似的问题,因此在 Global.asax > Application_Error 中编写了一个方法来专门处理.aspx"的情况,并且效果很好.
also works fine (note the lack of a second colon). Despite being the wrong URL, it does get handled by our URL forwarding system, which uses a custom 404 page. On the old system, we had a similar problem, so a method was written in Global.asax > Application_Error specifically to handle the '.aspx' case, and it worked fine.
在我们的新服务器上,Application_Error 永远不会在 Global.asax 中抛出.相反,我得到一个 System.NotSupportedException -不支持给定路径的格式".这个 System.NotSupportedException 是我们在 Global.asax 页面中处理的确切情况,所以它绝对不会被触发.
On our new server, the Application_Error never gets thrown in Global.asax. Instead, I get a System.NotSupportedException - "The given path's format is not supported". This System.NotSupportedException is the exact case we handle in the Global.asax page, so it's definitely not being fired.
我已经更改了几个论坛帖子中显示的注册表项,HKEY_LOCAL_MACHINESOFTWAREMicrosoftASP.NET VerificationCompatibility=1HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesHTTP|参数 AllowRestrictedChars=1
I've changed the registry keys indicated in several forum posts, HKEY_LOCAL_MACHINESOFTWAREMicrosoftASP.NET VerificationCompatibility=1 HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesHTTP|Parameters AllowRestrictedChars=1
我已尝试更改 .aspx 的处理程序映射设置.
I've tried changing the Handler Mappings settings for .aspx.
我尝试将应用程序池设置为使用经典模式而不是集成模式,但这会导致完全不同的错误,即图像和 CSS 等静态内容根本不显示.我已经检查过 Windows 功能中启用了静态内容,并且确实如此.在经典模式下,'.aspx' 请求会引发两个 Bad Request 错误,但绝对没有任何信息.我得到的错误页面的代码字面意思是
I've tried setting the App pool to use classic mode instead of integrated, but this causes a completely different error where static content such as images and CSS do not display at all. I've checked that static content is enabled in the windows features, and it is. Under classic mode, the '.aspx' request throws two Bad Request errors with absolutely no information whatsoever. The code of the error page I get is literally
错误请求<html><body>错误请求</body></html>
Bad Request<html><body>Bad Request</body></html>
更新:我已将静态文件处理程序映射更改为此页面中的表单http://improve.dk/blog/2006/12/11/making-url-rewriting-on-iis7-work-like-iis6但是,正如作者正确指出的那样,这是一种 hack,而不是 IIS7 下的正确处理方式.它也只修复了经典模式下的静态文件问题.'.aspx' 页面在经典模式下仍然会抛出错误.
UPDATE: I've changed the static file Handler Mapping to the form found in this page http://improve.dk/blog/2006/12/11/making-url-rewriting-on-iis7-work-like-iis6 However, as the author rightly points out, this is a hack and not the correct way of doing things under IIS7. It also only fixes the static file problem in classic mode. '.aspx' pages still throw an error under classic mode.
在这一点上,我们将不胜感激任何想法或意见.
Any thoughts or input would be greatly appreciated at this point.
推荐答案
IIS 7 解决方案
IIS 7 中的简单解决方案是在您的 web.config 文件中添加一个设置,以告诉 IIS 通过您的 Global.asax 事件处理所有请求.只需在 web.config 中添加或更改此部分即可启用请求:
The easy solution in IIS 7 is to add a setting in your web.config file to tell IIS to process all requests through your Global.asax events. Just add or change this section in your web.config to enable requests:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
这篇关于Global.asax 未触发 IIS7 中的 .aspx 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!