简体   繁体   English

Global.asax没有为IIS7中的.aspx页面触发

[英]Global.asax not firing for .aspx pages in IIS7

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 例如,这些格式之一是将目标URL附加到链接的末尾

http://url.fwd/abcd/http://www.mydomain.com/page.aspx HTTP://url.fwd/abcd/http://www.mydomain.com/page.aspx

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. 这是在过去两年中在Windows Server 2003 / IIS6上运行的,但现在我们正在尝试迁移到Windows Server 2008 / IIS7设置,它不再起作用了。

I've read about the problem with colons in the URL but it doesn't affect pages not ending in '.aspx'. 我已经读过URL中冒号的问题,但它不会影响不以'.aspx'结尾的页面。 For instance, 例如,

http://url.fwd/abcd/http://www.mydomain.com/page.php HTTP://url.fwd/abcd/http://www.mydomain.com/page.php

would redirect fine. 会重定向好。

http://url.fwd/abcd/http//www.mydomain.com/page.aspx HTTP://url.fwd/abcd/http//www.mydomain.com/page.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. 尽管URL错误,但它确实由我们的URL转发系统处理,该系统使用自定义404页面。 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. 在旧系统上,我们遇到了类似的问题,因此在Global.asax> Application_Error中专门编写了一个方法来处理'.aspx'的情况,并且它工作正常。

On our new server, the Application_Error never gets thrown in Global.asax. 在我们的新服务器上,Application_Error永远不会被Global.asax抛出。 Instead, I get a System.NotSupportedException - "The given path's format is not supported". 相反,我得到一个System.NotSupportedException - “不支持给定路径的格式”。 This System.NotSupportedException is the exact case we handle in the Global.asax page, so it's definitely not being fired. 这个System.NotSupportedException是我们在Global.asax页面中处理的确切情况,因此它绝对不会被触发。

I've changed the registry keys indicated in several forum posts, HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ASP.NET VerificationCompatibility=1 HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\HTTP|Parameters AllowRestrictedChars=1 我已经更改了几个论坛帖子中指示的注册表项,HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ ASP.NET VerificationCompatibility = 1 HKEY_LOCAL_MACHINE \\ SYSTEM \\ CurrentControlSet \\ services \\ HTTP |参数AllowRestrictedChars = 1

I've tried changing the Handler Mappings settings for .aspx. 我已经尝试更改.aspx的Handler Mappings设置。

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. 我已经尝试将应用程序池设置为使用经典模式而不是集成,但这会导致完全不同的错误,其中静态内容(如图像和CSS)根本不显示。 I've checked that static content is enabled in the windows features, and it is. 我已经检查过在Windows功能中启用了静态内容,它确实如此。 Under classic mode, the '.aspx' request throws two Bad Request errors with absolutely no information whatsoever. 在经典模式下,'。aspx'请求会抛出两个错误请求错误,绝对没有任何信息。 The code of the error page I get is literally 我得到的错误页面的代码就是字面意思

Bad Request<html><body>Bad Request</body></html> 错误请求<html> <body>错误请求</ body> </ html>

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. 更新:我已将静态文件处理程序映射更改为此页面中的表单http://improve.dk/blog/2006/12/11/making-url-rewriting-on-iis7-work-like-iis6但是正如作者正确指出的那样,这是一种黑客行为,而不是在IIS7下做事的正确方法。 It also only fixes the static file problem in classic mode. 它还只修复了经典模式下的静态文件问题。 '.aspx' pages still throw an error under classic mode. '.aspx'页面仍然在经典模式下抛出错误。

Any thoughts or input would be greatly appreciated at this point. 在这一点上,任何想法或意见都会受到高度赞赏。

IIS 7 Solution IIS 7解决方案

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. IIS 7中的简单解决方案是在web.config文件中添加一个设置,以告知IIS通过Global.asax事件处理所有请求。 Just add or change this section in your web.config to enable requests: 只需在web.config中添加或更改此部分即可启用请求:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

In my case, I was publish my site in production and I miss copy to server App_global.asax.compiled file. 在我的情况下,我在生产中发布我的网站,我错过了复制到服务器App_global.asax.compiled文件。 For this reason was not fire the Events inside Global.asax. 出于这个原因,没有触发Global.asax中的事件。

Hope anyelse help this tips, I lost 8 hours seeking. 希望任何帮助这个提示,我失去了8个小时的寻求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM