我有以下RouteLink
:MVC RouteLink URL格式
@Html.RouteLink("Accept Offer", new { controller = "Case", action = "Accept", id = item.CaseId, offerid = item.PxOfferId }, new { @class = "btn btn-success" })
哪些格式的网址为:
http://localhost:54644/Clients/Case/Accept/15847?offerid=3103
我如何格式化的网址是:
http://localhost:54644/Clients/Case/Accept/15847/3103
谢谢。
默认路由:
context.MapRoute(
"Clients_default",
"Clients/{controller}/{action}/{id}",
new { controller = "Login", action = "Index", id = UrlParameter.Optional }
);
路线的作品,如果我把这个第一次在我的定义路线:
context.MapRoute(
name: "Accept Offer",
url: "Clients/{controller}/{action}/{id}/{offerid}",
defaults: new { controller = "Case", action = "Accept", id = 0, offerid = UrlParameter.Optional }
);
但随后引起其他页面上的错误。
您需要使用'offerid'的占位符来定义特定路线。 –
尝试在路线配置中添加'offerId',例如:{controller}/{action}/{id}/{offerid}'并声明'offerid'作为'UrlParameter.Optional'。 –
你可以在'RouteConfig'中分享你有的路线定义吗?如果你没有设置,你需要这样做。然后,你将能够实现你需要的url格式 – scgough