Enabling Friendly URL in ASP.net Webforms

Sajil Prasad
intertoons
Published in
Sep 11, 2021

ASP.net Webforms projects will generate URLs that are tightly reflect the physical file with .aspx extension. Default Asp.net Webforms project url will look like

http://somewebsite/WebForm1.aspx

But as seen in modern web applications, unfortunately these URLs are not SEO friendly. And if you ever wish to change that “Unnecessary” .aspx extension, here is how.

  1. Create your webforms project
  2. Right Click on your project or solution to manage NuGet packages. Search and install “Microsoft ASP.NET Friendly URLs”.
  3. Now add Global.asax file if your project doesn’t have one.
  4. Add the below code snippet
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.EnableFriendlyUrls();
}

For this, you have to refer two namespaces

using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;

5. That’s all. You are done!

--

--