This blog post summarizes a few approaches you can take to cleanly map or rewrite URLs with ASP.NET, and have the option to structure the URLs of your application however you want.
But before we go for approaches lets understand the significance of putting efforts in rewriting.
Why does URL mapping and rewriting matter?
· Cases where you want to restructure the pages and you want to ensure that people who have bookmarked old URLs don't break when you move pages around.
· Improving the search relevancy of pages on your site with search engines like Google, Yahoo and Live. For .e.g
o Moving from using querystring arguments to instead use fully qualified URL's (for example: http://www.store.com/products.aspx/Books instead of http://www.store.com/products.aspx?category=books) can also in some cases increase your priority in search engine results.
o Using techniques that force referring links to use the same case and URL entrypoint (for example: weblogs.asp.net/scottgu instead of weblogs.asp.net/scottgu/default.aspx) can also avoid diluting your pagerank across multiple URLs, and increase your search results.
In a world where search engines increasingly drive traffic to sites, extracting any little improvement in your page ranking can yield very good ROI to your business. For a list of some good Search Engine Optimization (SEO) suggestions, I'd recommend reading the SSW Rules to Better Google Rankings, as well as MarketPosition's article on how URLs can affect top search engine ranking.
· Use Request.PathInfo Parameters Instead of QueryStrings
· Using an HttpModule to Perform URL Rewriting
· Using an HttpModule to Perform Extension-Less URL Rewriting with IIS7
· ISAPIRewrite to enable Extension-less URL Rewriting for IIS5 and IIS6
To know about these aproaches in detail access the link here.
One more Aproach…
· Specify the remapping in your application's web configuration file.
Determine the Url:
When working with remapped URLs, you often need to determine the original URL that a user requested. For example, you might want to display a message that tells users to update their bookmarks (favorites) to point to the new URL.
· Request.RawUrl - Returns the original URL (before being remapped).
· Request.Path - Returns the current URL (after being remapped).
· Request.AppRelativeCurrentExecutionFilePath - Returns the application relative URL (after being remapped).
e.g. For the above defined URL Mappings in Web.Config, below are the results.
· Request.RawUrl = /UrlMappingsApp/Home.aspx
· Request.Path = /UrlMappingsApp/Default.aspx
· Request.AppRelativeCurrentExecutionFilePath = ~/Default.aspx
Hope this helps.
See my earliar post on it. Click here.