0

我有两条路线

   context.MapRoute("",
                "Route1/{controller}/{programid}/{action}"
            );

   context.MapRoute("",
                "Route2/{controller}/{programid}/{action}"
            );

Url.Action("action2", "controller2", new{programid = 123});

结果 URL:Route1/controller2/123/action2

是否可以获得以下网址:

预期网址:Route2/controller2/123/action2

4

1 回答 1

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"}}
于 2013-10-03T15:06:59.410 回答