我有两条路线
context.MapRoute("",
"Route1/{controller}/{programid}/{action}"
);
context.MapRoute("",
"Route2/{controller}/{programid}/{action}"
);
Url.Action(“action2”,“controller2”,new {programid = 123});
结果网址:Route1 / controller2 / 123 / action2
是否可以获得以下网址:
预期网址:Route2 / controller2 / 123 / action2
答案 0 :(得分:0)
将路线修改为
context.MapRoute("Route1",
"Route1/{controller}/{programid}/{action}"
);
context.MapRoute("Route2",
"Route2/{controller}/{programid}/{action}"
);
然后使用Url.RouteUrl之类的
Url.RouteUrl("Route1", YourRouteProperties }
或
Url.RouteUrl("Route1", new { controller = "YourController", action = "YourAction",
programid= "YourProgramId"}}