我刚刚启动了 MVC,我可以将一个 ID 传递给一个页面,但似乎无法让我的路由使用两个参数。有谁知道为什么?
这是我的代码:
全球的:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "Login", id = UrlParameter.Optional }
);
routes.MapRoute(
"EditVoucher", // Route name
"{controller}/{action}/{id}/{userid}", // URL with parameters
new { controller = "Admin", action = "EditVoucher", id = "", userid = "" } // Parameter defaults
);
**My controller:**
[HttpGet]
public ActionResult EditVoucher(int ID, int UserID)
{
}
**my link:**
@Html.ActionLink("[Edit]", "EditVoucher", new { Controller = "Admin", id = item.ID, userid = 2 })
this passes through the values fine but I end up with this sort of URL:
**/Admin/EditVoucher/2?userid=2**
thanks