Friday, July 18, 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">Departmenta><br />
<a href="Product.aspx">Producta><br />
<a href="Employee.aspx">Employeea>

No comments: