How can I have an action link with two Ids. (I am using areas). The Id2 gets rendered as a querystring.
Controller
public ActionResult View(int id, int id2)
Route
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
"Admin_default2",
"Admin/{controller}/{action}/{id}/{id2}",
new { action = "Index"}
);
ActionLink
@Html.ActionLink("Click", "News/View", new { area = "Admin", id = 1, id2 = 2 }, null)
Rendered Link
/Admin/News/View/1?id2=2
Expected Link
/Admin/News/View/1/2
Try adding the more specific route (Admin_default2) first.
So, your mapping code would look like: