Monday, 28 January 2013 13:57 routing for url rewriting

Written by 
Rate this item
(0 votes) routing is easy to use for rewriting any url.

if you have a url like
but if you want to have it in short name for marketing or for anything
you want like this is the resulting url -

then following is the way how to do it -

in your site in global.asax code behind file add the routing this way -

public static void RegisterRoutes(RouteCollection routeCollection)
routeCollection.RouteExistingFiles = false;
routeCollection.MapPageRoute("RouteForCustomer", "Projects/{Id}", "~/Projects.aspx");
protected void Application_Start(object sender, EventArgs e)

here you define how the route url will look like and the physical file
Projects.aspx in manageRoute method.

then in the Projects.aspx page load method you can access the username value
this way -

string User_Name = Page.RouteData.Values["Id"].ToString();

Read 3109 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.