没有命名查询变量的ActionLink

时间:2011-09-19 10:52:40

标签: c# asp.net routes actionlink

我有一个生成此URL的ActionLink

@Html.ActionLink("Hardware Profile", "Profile", "Device", new { id = 2, tab = "hardware"}, null)

//Produces: http://localhost:7946/Device/Profile/2?tab=hardware

但我想要它产生的是:

http://localhost:7946/Device/Profile/2/hardware

我有以下路线设置

routes.MapRoute(
                "DeviceProfile",
                "device/profile/{id}/{tab}",
                new { controller = "Device", action = "Profile", id = UrlParameter.Optional, tab = UrlParameter.Optional }
            );

我如何实现这一目标?

0 个答案:

没有答案