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
- Install Nuget package.
To start with asp .net friendly urls you need to install following Nuget package.
- Files installed by friendly urls in asp .net
Nuget will automatically install following files and folders in your application:
Note: "Site.Mobile.Master" and "ViewSwitcher.ascx" are optional files you can delete these files if not required.
- Add Global.asax file.
Add Global.asax file in your application and add following lines of code:
void Application_Start(object sender, EventArgs e)
- Add new pages and test application
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
Remove .aspx from url in asp.net demo: