Wednesday, 8 January 2014

How to hide a .aspx extension in browser using asp.net c#?

Hello Friends,
Today i'll tell you, how to hide extension of ur .ASPX page in Dot Net. i am explaing it by creating a small project.

Step 1 : Create a new website and add one Global.asax file.

Step 2 : In Application_Start method you need to Write

           RouteTable.Routes.MapPageRoute("StoreRoute", "HideExtension/{Name}", "~/{Name}.aspx");




Step 3 : Take one master page or Default page, take Linkbutton to create a Menu bar like this. i m taking three page Name is Index.aspx, Company.aspx and Client.aspx.



Step 4 : In source code of Hyperlink button, you need to initialize navigateurl  with your RouteUrl

<asp:HyperLink runat="server" id="h1" Text="index" NavigateUrl="<%$RouteUrl:Name=Index %>">Home</asp:HyperLink>
  

Now after running your site, you can see after clicking on every button(Hyperlink Button) you got the page with no extension.