I am writing classic asp.net website and struggling with a problem.
Usually in URL send data by doing this: localhost/MyrandomPage.aspx?UserName=RandomUsername
But i am trying to make a page more personal so i want Url to look like this:
localhost.com/Profile/RandomUsername
And i am cant find a way how to retrive RandomUserName after slash in Url.
ive done Routing:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("",
"/Pages/{UserName}",
"~/Pages/Profile.aspx");
}
But how do i retrive UserName??
You should be able to get it using
Page.RouteData.Values["UserName"] as stringScott Gu has a good blog post covering routing in webforms.