I created a new Web Forms (ASP.NET 4.5) project and I'm trying to get URL routing to work.
RouteConfig.cs
looks like this:
routes.MapPageRoute("surveyhome", "survey/home", "~/Survey.aspx");
routes.MapPageRoute("surveyquestions", "survey/questions/{q}", "~/Survey.aspx");
I have a link that looks like this:
<a href="/survey/questions/1">1</a>
It correctly loads the Survey.aspx
page, so I know it's partly working, but this code (in the codebehind of that page) doesn't work:
if (Page.RouteData.Values["q"] != null)
{
// do something
}
It's always null. Why?