Easiest way to remove .aspx from url in asp.net

In this asp .net tutorial we will learn about how to remove .aspx extension from url in asp .net. For this we will use Friendly URLs in asp .net

  1. Install Nuget package.
  2. To start with asp .net friendly urls you need to install following Nuget package.
                    Install-Package Microsoft.AspNet.FriendlyUrls
                
    For more info you can check How to install nuget packages in asp .net.

  3. Files installed by friendly urls in asp .net
  4. Nuget will automatically install following files and folders in your application:

     

    Easiest way to remove .aspx from url in asp.net

     

    Note: "Site.Mobile.Master" and "ViewSwitcher.ascx" are optional files you can delete these files if not required.

  5. Add Global.asax file.
  6. Add Global.asax file in your application and add following lines of code:
                void Application_Start(object sender, EventArgs e)
                {
                   RouteConfig.RegisterRoutes(System.Web.Routing.RouteTable.Routes);
                }
            

  7. Add new pages and test application
  8. This is all you need to remove .aspx from url in asp .net. Add 2 new pages to test the application. Here I have used "Default.aspx" and "About.aspx".

    Default.aspx page source

            

    This is Home Page

    Go to About Page

    About.aspx page source

            

    This is about us page.

    Go to Home Page.

Remove .aspx from url in asp.net demo:

Easiest way to remove .aspx from url in asp.net demo
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
3 + 2 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2017 CodingFusion