views:

777

answers:

2

I have an ASP.NET 3.5 application that started in 1.1 and has been ported from IIS5 to IIS6 and now we're going to IIS7. Back in the 1.1 days we implemented URL-rewriting functionality based on HTTP Modules that still works great - fairly complex logic that is very stable. It allows us to take URL's like this

www.abc.com/merchant

and figure out that 'abc' represents a brand of products and 'merchant' is one of many companies that sell that brand. So far so good.

Along the way we have had some merchants close, others merge, etc. To preserve the URL's for them, we will sometimes use IIS6's virtual-directory-redirection capability to redirect www.abc.com/oldMerchant to www.abc.com/newMerchant, or to something else entirely, like www.micorsoft.com - who knows. There are about a dozen of these now.

I am trying to do the same in IIS7 and I've found many posts describing differnet mechanisms (like this). The biggest problem I have is that in IIS7 the virtual root paths STILL go thru my URL rewrite logic, while they didn't in IIS6. That is, instead of redirecting www.abc.com/oldMerchant to www.abc.com/newMerchant, the URL rewriting sees it first and concludes that oldMerchant isn't a valid merchant (as it should).

Before I go down a coding road to solve this problem, does someone know of a magical switch I've missed?

A: 

my eyes are rolling back in my head.

That is, instead of redirecting www.abc.com/oldMerchant to www.abc.com/newMerchant, the URL rewriting sees it first and concludes that oldMerchant isn't a valid merchant (as it should).

So, in your rewrite logic, can you not include appropriate redirect rules for the sites you want to redirect? (I'm assuming a redirect is possible in the IIS7 Rewrite Module).

Cheeso
That is certainly possible. The problem I have in this case is the record for 'oldMerchant' is flat-out gone. I was hoping I could solve this problem with IIS and without coding like I could in IIS6.
n8wrl
Ok, Gotcha. Not sure what's changed, but maybe if you special case 'oldMerchant' to redirect it to a 404 page or whatever, it will satisfy.
Cheeso
A: 

Are you running IIS7 in integrated or classic mode? I expect you are running in integrated mode. That's the new mode that sends all of the traffic through the .Net pipeline. If you switch to classic mode, I think it might start working for you again.

David
Integrated mode, so that makes sense.
n8wrl
if he move to classic mode, then he will mis the IIS 7 feature, classic mode is actually IIS 6 http://blogs.msdn.com/tmarq/archive/2007/08/30/iis-7-0-asp-net-pipelines-modules-handlers-and-preconditions.aspx
Muhammad Akhtar
Indeed. Modifying the code is the best answer.
David