The other day I commented on how the IIS 7 URL Rewriter can be a neat way to transition your legacy ASP.NET Web Forms URL’s consisting of querystrings to a more RESTful, searchengine-friendly syntax. Actually, this can either be 1) a more transitory solution until you move to the new ASP.NET 4 Web Forms Routing or ASP.NET MVC, or 2) a permanent solution if you have a legacy application that you don’t plan to upgrade but want the cleaner routing.
After about 15 minutes of playing with the URL Rewriter I was pretty amazed at how quickly and easily one can clean up the inbound at outbound URL’s using it.
I created a page on my localhost that displayed products for a particular category for an e-commerce website and accepted the category as a querystring parameter as such:
I wanted to map this URL for both inbound and outbound links to something cleaner, like:
My thought was that this would be a fair amount of work, but in reality the IIS 7 URL Rewriter makes this a breeze.
Once you have installed the IIS 7 URL Rewriter you have the ability to add a rule, and in this specific case, a User-friendly URL, that is located under the header, Inbound and Outbound Rules.
Now this is where it gets slick. One enters the original URL and then chooses a more User-friendly URL from a dropdown and lets the URL Rewriter handle the rest. If, of course, you want more control you can pick another rule, but this worked perfectly for what I had in mind.
After you save the rule, your inbound routes will work correctly for any category as such:
Also, all links to this page within the website will automagically be converted from the old querystring URL to the more searchengine-friendly URL on your behalf, no work required. Very, very slick.
If you could benefit from more searchengine-friendly URL’s, the IIS 7 URL Rewriter is worth a look. I was pretty impressed with what I could do in just 15 minutes. After a bit more understanding, I’ll definitely be showing it off at a future Sarasota Web Developer Group Meeting.