I’m moving my first steps on asp.net mvc, and in my test project I added a route after the default one in this way.
As you can see the second route is used when the controller need the concept of current page, it is very close to the default one, but it has another parameter called pageid. Now I generate a link to the paged controller with the following code.
But generated link is PhotoManager/ManageAlbum/00000000-0000-0000-0000-000000000000?pageid=0 that is wrong. The page id was put in querystring and not in the path as I want. The problem is derived from the order of routes, because the ActionLink function scans route from the first to the last. Since the first route match with the parameter the ActionLink method decides to use the Default route, appending the pageid parameter to the querystring.
If you need to manually choose the route you need to generate your link you can use a different method of the Html helper object.
As you can see with the RouteLink() method you can choose exactly the route you want to use, and generate desidered link /ManageAlbum/PhotoManager/0/00000000-0000-0000-0000-000000000000.
Tags: Asp.net MVC