Can anyone explain why this code with the given routes returns the first route?
routes.MapRoute(null, "user/approve", new { controller = "Users", action = "Approve" }),
routes.MapRoute(null, "user/{username}", new { controller = "Users", action = "Profile" }),
routes.MapRoute(null, "user/{username}/{action}", new { controller = "Users" }),
routes.MapRoute(null, "user/{username}/{action}/{id}", new { controller = "Users" }),
routes.MapRoute(null, "search/{query}", new { controller = "Artists", action = "Search", page = 1 }),
routes.MapRoute(null, "search/{query}/{page}", new { controller = "Artists", action = "Search" }),
routes.MapRoute(null, "music", new { controller = "Artists", action = "Index", page = 1 }),
routes.MapRoute(null, "music/page/{page}", new { controller = "Artists", action = "Index" })
var pageLinkValueDictionary = new RouteValueDictionary(this.linkWithoutPageValuesDictionary);
pageLinkValueDictionary.Add("page", pageNumber);
var virtualPathData = RouteTable.Routes.GetVirtualPath(this.viewContext.RequestContext, pageLinkValueDictionary);
Here GetVirtualPath always returns user/approve, although there is no {page} parameter in the route. Furthermore, everything works as expected without the first route.
I have found this link http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2033 but it wasn't very helpful. It looks like GetVirtualPath was not implemented with large collections of routes in mind.
I am using ASP.Net MVC 1.0.