How to remove .aspx extension from url in Asp.Net?


Microsoft has introduced a package “Microsoft.AspNet.FriendlyUrls” for user friendly urls.
Install Microsoft.AspNet.FriendlyUrls from NuGet Gallery in your Application Project. It will install several files in your project.

  • App_Start Directory with RouteConfig.cs file.
  • packages.config file
  • Site.Mobile.Master
  • ViewSwitcher.ascx

Microsoft.AspNet.FriendlyUrls

Microsoft.AspNet.FriendlyUrls


Now just add “Global.asax” file in your project from Add New item…
Update Application_Start method with below lines of code.

protected void Application_Start(object sender, EventArgs e)
{
    RouteConfig.RegisterRoutes(RouteTable.Routes);
}


Now run your Application.