URL Mapping in ASP.Net

Hello Everybody,

Yesterday one of my colleague was very much confused in URL mapping, he wanted to show a meaningful url without any extension. He was trying to do some extra things and very much inconvenience method. I suggest him a very simple and useful technique from net.
Here is how it works:


<div>
    <asp:Menu ID="menuTop" runat="server" Orientation="Horizontal" Width="400px">
    <Items>
    <asp:MenuItem Text="Login" ToolTip="Login" NavigateUrl="~/Login"></asp:MenuItem>
    <asp:MenuItem Text="Result" ToolTip="Login" NavigateUrl="~/Result"></asp:MenuItem>
    <asp:MenuItem Text="Advertise" ToolTip="Advertise" NavigateUrl="~/Advertise"></asp:MenuItem>
    </Items>
    <StaticMenuItemStyle BackColor="Aqua" ForeColor="Brown"  Font-Bold="true" Height="20px" Font-Names="segoi ui" ItemSpacing="1px" />
    <StaticHoverStyle BackColor="BurlyWood" />
    </asp:Menu>
    </div>

Web.Config Settings:
Write the below code inside

<urlMappings>
      <add url="~/Login" mappedUrl="Login.aspx"/>
      <add url="~/Result" mappedUrl="SearchResult.aspx"/>
      <add url="~/Result" mappedUrl="SearchResult.aspx"/>
      <add url="~/Advertise" mappedUrl="Advertise.aspx"/>
</urlMappings>

In above setting URL is your new URL with mapped path, ~ sign is mandatory and mappedURL is your old url

I hope it will help you out …
Cheers,
Ved Pathak

Comments

Hitesh Patel said…
Hi Ved, Good Tutorials Provided by you. I am having Problem when using url without .aspx extension as explained by you. ihave to use myAdvertise.aspx in url.
Hitesh Patel said…
add url="~/myAdvertise" mappedUrl="Advertise.aspx"
VedPathak said…
Dear Mr. Hitesh,
Thank you for your valuable feedback, First of all I want to know what problem you are facing as your code seems very right to me. And it should work accordingly. kindly explain me what exactly are you facing..

Thanks again.
Regards,
ved pathak
Hitesh Patel said…
This comment has been removed by the author.
Hitesh Patel said…
Thanks for your reply ,
  I am developing samples for my students in asp.net . I want a functionality in which the extension of page is not displayed in url. Also I don't want to make seperate directories for individual pages. I have lot of pages.

For example 
http://www.flipkart.com/samsung-galaxy-s-duos-2-s7582/

http://www.flipkart.com/cameras


http://www.flipkart.com/moto-e/


Is it possible by url mapping.

Regards ,
Hitesh
Sent from Mobile.
VedPathak said…
Dear Mr. Hitesh,

Sorry to delayed I was out of station, so was not able to reply you.

Here I found your requirements as I think you need:

http://www.c-sharpcorner.com/UploadFile/akkiraju/url-rewriting-in-Asp-Net/

Please let me know.