在我的表中,我有两个链接:
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Events", "LocationEvents", "Events", new {locationId = item.Id}, null)
现在我的目标是当我将鼠标悬停在链接上时,我希望两者的 url 看起来像这样:
/Locations/Edit/4
/Events/LocationEvents/4
但是,我得到了这个:
/Locations/Edit?id=4
/Events/LocationEvents/4
这是我的 RouteConfig.cs
routes.MapRoute(
name: "Events",
url: "{controller}/{action}/{locationId}",
defaults: new {controller = "Locations", action = "Index", locationId = UrlParameter.Optional}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Locations", action = "Index", id = UrlParameter.Optional }
);
我该如何进行这项工作?