有没有办法在不改变动作或调用的控制器的情况下更改 mvc 中给定动作的 URL?
如果是这样,如何在以下 MapRoute 上完成:
routes.MapRoute(
"Estate.CloseDeal",
"Estate/CloseDeal/{groupId}/{paymentType}/{mortgageValue}/{province}",
new { controller = "Estate", action = "CloseDeal" },
new { groupId = "\\d+", paymentType = "\\d+", mortgageValue = "\\d+", province = "\\d+" }
);
所需的 URL 是:“.../estate-support/deal-closing/...”。目前它显示为“.../Estate/CloseDeal/...”
链接到此操作的按钮如下所示:
<button detail="@Url.Action("CloseDeal", new { groupId = info.GroupId })" class="orange">
编辑1:
尝试更改为:
routes.MapRoute(
"Estate.CloseDeal",
"estate-support/deal-closing/{groupId}/{paymentType}/{mortgageValue}/{province}",
new { controller = "Estate", action = "CloseDeal" },
new { groupId = "\\d+", paymentType = "\\d+", mortgageValue = "\\d+", province = "\\d+" }
);
此返回错误:您要查找的资源已被删除、名称已更改或暂时不可用。
编辑2:
更改第二个字符串适用于除此之外的所有路由 - 不同之处在于,此路由具有附加参数(groupID、paymentType 等)。