在我的 MVC 4 应用程序中,我使用了 Area,这是我的路线:
context.MapRoute(
"Service_AcceptBid",
"Service/{controller}/{action}/{id}/{accept}",
new { area = "Service", controller = "Project", action = "AcceptBid", id = UrlParameter.Optional, accept = UrlParameter.Optional }
);
context.MapRoute(
"Service_BidNegotiation",
"Service/{controller}/{action}/{id}/{bid}",
new { area = "Service", controller = "Project", action = "Negotiations", id = UrlParameter.Optional, bid = UrlParameter.Optional }
);
我将这些链接放在我的 .cshtml 页面上:
<div dir="ltr">
@Html.RouteLink("Accept", "Service_AcceptBid", new { controller = "Project", action = "AcceptBid", Id = item.ProjectId, Accept = item.Id })
@Html.RouteLink("Negotiate", "Service_BidNegotiation", new { controller = "Project", action = "Negotiations", Id = item.ProjectId, Bid = item.Id })
</div>
当第一个链接被点击时,AcceptBid
控制器被调用并且它的参数(Id,Accept)被设置为url值。但是当我点击第二个链接时,控制器方法中的 Id 参数已设置,但第二个参数(Bid)为空。
为什么会这样?
我能做些什么来解决这个问题?
谢谢。