5

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

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.

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

would redirect fine.

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. 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.

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.

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

I've tried changing the Handler Mappings settings for .aspx.

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

Bad Request<html><body>Bad Request</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. 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.

roryok
  • 9,325
  • 17
  • 71
  • 138
  • FYI: I Never found a solution for this. We had to revert to using a classic ASP page to handle all incoming traffic and remove any suffixed URLs ending with '.aspx', then pass them on to the ASP.NET stack. I'm very unhappy with this solution but its the only one we've been able to find. If anyone has any ideas on how to get Global.asax firing in IIS7 for these requests I would love to hear them. – roryok Jul 30 '10 at 14:13
  • 1
    Just as an update, back in '09 I posted a followup to my original hack, detailing how to make it work the proper way: http://improve.dk/archive/2009/10/14/how-to-do-url-rewriting-on-iis-7-properly.aspx :) – Mark S. Rasmussen Sep 08 '11 at 22:36

2 Answers2

9

IIS 7 Solution

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>
Florian Winter
  • 4,750
  • 1
  • 44
  • 69
Manoj
  • 91
  • 1
  • 2
1

In my case, I was publish my site in production and I miss copy to server App_global.asax.compiled file. For this reason was not fire the Events inside Global.asax.

Hope anyelse help this tips, I lost 8 hours seeking.

Hernaldo Gonzalez
  • 1,977
  • 1
  • 21
  • 32
  • Yes. I tried pre-compiling the app and deploying it, and then I tried it without pre-compilation, and it didn't delete the old files. So they were messing it up! – Shiroy Jul 01 '19 at 23:47