RouteData.Values stays Empty

c#, routes, web

Solution

Following code has worked for me, I have moved additional routes to top of the function.

Also, in my case RedirectMode is off because I'm using Jquery in my code and inorder to make a Webmethod work, I have turned off RedirectMode.

void RegisterRoutes(RouteCollection routes)
{
     /* ... additional routes */
    routes.MapPageRoute("","Person/{IDP}", "~/Person.aspx");

    var settings = new FriendlyUrlSettings();
    settings.AutoRedirectMode = RedirectMode.Permanent;
    routes.EnableFriendlyUrls(settings);

}

Problem

My Code for the Route looks like this: ``` RouteTable.Routes.MapPageRoute("IDP", "Person/{IDP}", "~/Person.aspx") ``` And now i want to get the Data on a Form, normally it works like this: ``` int id = Convert.ToInt32(Page.RouteData.Values["IDP"]); ``` But everytime i try to get the Data from the Route e.g.: `http://PC-81/SkillDatenbank/Person/1` I get no Data from the Value (it is empty!) I am using ASP.Net 4.5 with Web Forms. Edit: I made an new Project and tested and it didnt work either What am i Doing wrong? in the Last Project it did work like this :( Can you help me?

Original source

Related problems