Wednesday, January 5, 2011

URL Mapping in ASP.Net 2.0

URL mapping is often used to provide "friendly" URLs, which are URLs that are more readable and sensical
- Beverages.aspx is a "friendly" URL as it is more readable than ProductsByCategory.aspx?CategoryID=1&CategoryName=Beverages. URL mapping also is useful when restructuring a site.
Imagine that all product information was accessible through,
but the higher-ups want the products rooted available through
instead. Clearly, any users who have the old links bookmarked or linked from a website will get 404s if they visit
once the folder name change has been made. This can be mitigated by using URL mapping to map each page in
the Products folder to its corresponding page in Catalog.

ASP.Net 2.0 provides a simple way to map a long URL to a short URL with the help of   <urlMappings> tag in
Web.Config. With this feature URL rewritting becomes simple but with some big limitations.

For example,

      <add url="~/Csharp.aspx"       
      <add url="~/ASPNet.aspx"        
      <add url="~/Framework.aspx"        

The above config settings routes the user to the URL given in mappedUrl property and thus makes the
URL very simple and easily rememberable.
The drawback of this feature is when our websites grows drastically then maintaining this section in
config file will be tedious.  To overcome this we can build a URL rewriting module using Regular expression.

1 comment :

  1. Need To Increase Your ClickBank Traffic And Commissions?

    Bannerizer makes it easy for you to promote ClickBank products by banners, simply go to Bannerizer, and grab the banner codes for your chosen ClickBank products or use the Universal ClickBank Banner Rotator to promote all of the ClickBank products.