Last post Mar 15, 2010 10:10 AM by awaiss
Mar 11, 2010 10:14 AM|awaiss|LINK
We have multiple versions of our application on our web servers (our customers don't like to be forced into upgrading). Each version is a separate application in IIS (e.g. mydomain.com/v1, mydomain.com/v2, etc). Each of our customers has a unique ID and
we have a database that includes which version the customer is on.
What I'd like to do is have a friendly URL that would use the customer ID in the URL and direct them to the proper application's login page (e.g. mydomain.com/cust1 would map to v1 while mydomain.com would map to v2). I can do this with Response.Redirect,
but then the user's URL changes so if they tried to bookmark the login page, they would bookmark the login page for that version of the application. I get errors when I try to use RewritePath that seem to have to do with it crossing application boundaries.
Is such a thing possible? Or is there some other method of accomplishing the same thing?
Mar 15, 2010 02:40 AM|Song-Tian - MSFT|LINK
ASP.NET 2.0 provides some basic tools for us to use to write our own
URL rewriting engine, but before we talk about them, I need to point out that they have one serious limitation.
If you want to use .NET code to rewrite URLs, you can only do so for pages that end in
.aspx or some other extension that’s handled by the aspnet_isapi.dll
ASP.NET handler in IIS. You can see which file extensions are mapped to each handler in the
Application Configuration dialog in IIS.
The only available workaround is to remap file extensions in IIS so that
every single file type, not just the ones ending in .a??xx, are handled by
aspnet_isapi.dll. This undertaking is known as wildcard mapping, and it’s a very invasive change. It means that every file—including static HTML files, images, CSS files, and so forth—will be
passed through aspnet_isapi.dll. However, it doesn’t work perfectly: wildcard mapping can’t deal with URLs that refer to directories. In short, it’s a scorched-earth solution with a lot of problems, which is why I don’t recommend
So, what are our options? Well, I have some good news, and some bad news.
The bad news is that it’s difficult to undertake proper
URL rewriting using only .NET code. If you’re serious about URL rewriting, you shouldn’t be doing it in .NET code at all—you should be doing it at the web server level.
The good news outweighs the bad, though:
In IIS 5.x and 6, you can install third-party ISAPI add-ins to enable proper
In IIS 7, .NET code can be hooked into the rendering pipeline, so you can write a true .NET
URL rewriter at last.
Mar 15, 2010 10:10 AM|awaiss|LINK
Sorry, I forgot to mention that I am working with IIS7. I created an HttpModule and used the ResolveRequestCache event of the HttpApplication. It errors when I try to send it to another application - that's the problem.