This is an effective duplicate. How to stop ASP.Net MVC Html.ActionLink using existing route values?
According to @Eilon -
Because, as soon as you cancel the parameter segment, all parameter segments after it become invalid.
In my case, I have two Action links that reference actions on separate controllers.
Both actions have an optional page parameter.
Route configurations look like this:
routes.MapRoute(
"",
"blog/page{page}",
new { controller = "Blog", action = "Index" },
new { page = @"\d+" }
);
routes.MapRoute(
"",
"blog/{id}",
new { controller = "Blog", action = "Post" }
);
routes.MapRoute(
"",
"blog",
new { controller = "Blog", action = "Index" }
);
routes.MapRoute(
"",
"projects/page{page}",
new { controller = "Project", action = "Index" },
new { page = @"\d+" }
);
routes.MapRoute(
"",
"projects/{id}",
new { controller = "Project", action = "Project" }
);
routes.MapRoute(
"",
"projects",
new { controller = "Project", action = "Index" }
);
The problem is that if I go to page 2 of the projects and follow the link in the blog, I will be redirected to / blog / page 2.
, , ( , ), . , ActionLink , RouteValueDictionary?
ActionLink, "page" RouteData.
,