Articles → .NET → URL Mapping In ASP.NET
URL Mapping In ASP.NET
http://Yoursite/ProductsByCategory.aspx?CategoryID=1&CategoryName=Beverages
http://Yoursite/Beverages.aspx
Implementation
- Add urlMappings tag in web.config file inside system.web tag.
- Set enabled attribute of urlMappings tag to true.
- Put add tag as a child tag of urlMappings.
- Add url as an attribute of add tag. If we consider the example which I have mentioned earlier "~/Beverages.aspx" will be the value of url.
- Add mappedUrl as another attribute of add tag.In the above example "~/ProductsByCategory.aspx?CategoryID=1&CategoryName=Beverages" will be the value of mappedUrl.
Code
<configuration> …
<system.web>
…
<urlMappings enabled="true">
<add url="~/Beverages.aspx" mappedUrl="~/ProductsByCategory.aspx?CategoryID=1&CategoryName=Beverages" />
</urlMappings>
…
</system.web>
…
</configuration>