Tuesday, January 15, 2008

URL Mapping in asp.net 2.0

URL Mapping is a mechanism by which you can change the displayed url in address bar.

Example:

Your asp.net application is developed from years, with convention frm as prefix to webform.

Now to change already assigned name to legacy system which is maintained for past few years and to avoid risk we can make use of URL Mapping.


For URL Mapping
Step1: Add Mapping URL in web.config file.
<system.web>
<
urlMappings enabled="true">

<add url="~/Department.aspx" mappedUrl=" oldforms/frmDept.aspx"/>

<add url="~/Employee.aspx" mappedUrl=" oldforms/frmEmployee.aspx"/>

<add url="~/Product.aspx" mappedUrl=" oldforms/frmProduct.aspx"/>

</urlMappings>

</system.web>


Step2: Change the URL in .aspx file

<a href="Department.aspx">Department</a><br />

<a href="Product.aspx">Product</a><br />

<a href="Employee.aspx">Employee</a>


Step3: Now Check your ugly looking URL, it is replaced with New desired URL.

Before URL Mapping


After URL Mapping



3 comments:

Software Engineer said...

Hii,
Your concept is good but one can access the page with the name "Department.aspx" also with the name frmDept.aspx. So where is the security for url ???

Thanks,
Navin C

Ami said...

Use URL Rewriting Approach


http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html

Rajan said...

Thanks 4 help.
But if we have to show the list of visited pages & go back to any page then how to do this? plz tell me.

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape