This tutorial will show you how to use URL mapping technology in ASP.NET 2.0 and C#.The URL mapping feature uses configuration information stored
in web.config to remap incoming requests to a different URL.
How to use URL mapping in ASP.NET 2.0 and C#
This tutorial will show you how to use URL mapping technology in ASP.NET 2.0 and C#.
The URL mapping feature uses configuration information stored
in web.config to remap incoming requests to a different URL. The
remapping occurs prior to any other processing for the inbound request.
Although the sample below demonstrates remapping a page request, any
arbitrary file type can have its request remapped to a different URL.
At first you need to build a sitemap file Web.sitemap.
Secondly, please build a web.config file. The code is as following::
url="~/News.aspx" mappedUrl="~/UrlMappingVB.aspx?category=news" />
url="~/Category.aspx" mappedUrl="~/UrlMappingVB.aspx?category=default" />
url="~/Games.aspx" mappedUrl="~/UrlMappingVB.aspx?category=games" />
url="~/Health.aspx" mappedUrl="~/UrlMappingVB.aspx?category=health" />
|
The front end UrlMappingCsharp.aspx page looks something like this:
The current virtual path for the request is: <% Response.Write(Request.Path)%>.
The
value of the category querystring variable is: <%
Response.Write(Server.HtmlEncode(Request.QueryString("category")))%>.
However,
the original path that was requested before it was remapped
is: <% Response.Write(Request.RawUrl)%>.
|