I need to use routing with parameters in my ASP.NET application.
public class Global : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
var routes = RouteTable.Routes;
routes.MapPageRoute(
"Profile",
String.Format("{0}/{{{1}}}/", "Profile", "Id"),
"~/Views/Account/Profile.aspx",
false,
new RouteValueDictionary {{"Id", null}});
}
}
Then, by navigating to "/Profile" I want to get on Page_Load method Request.Params["Id"] as null and by navigating to "/Profile/1", Request.Params["Id"] as "1".
Where I made mistake?