AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Thursday 31 December 2015

Create ASP.NET MVC type route URLs in Web Form application

In this blog post we are discussing How to create ASP.NET MVC type route URLs in Web Form application. We already aware that MVC follows model, view & controller architecture & its URL don't contain .aspx or.cshtml extensions in suffix.  We create similar URLs in Web form application that URL will not contain an .aspx extension in suffix & your URL will look similar to MVC URL pattern. This will be done by URL rewriting.
URL Rewriting
URL Rewriting is done in the Application_Start method of Global.asax file. Where you need to define your all routes.
My Login & Contact us  routes are

I want to change my routes so I need to register routes in Global.asax

void Application_Start(object sender, EventArgs e)
        // Code that runs on application startup

   public static void RegisterRoutes(RouteCollection routes)
        routes.MapPageRoute("login", "login", "~/Login.aspx");
        routes.MapPageRoute("contactus", "contactus", "~/Contact.aspx");
Now new URL are


Post a Comment

  • Popular Posts
  • Comments