I'm trying to utilize the HTML.ActionLinks in MVC. I have a route definition like so:

routes.MapRoute(
    name: "RestaurantCommon",
    url: "Rest/{siteName}/Admin/{action}/{id}",
    defaults: new { controller = "AdminCommon", action = "Promotions", id = UrlParameter.Optional }
);

Is it possible to use ActionLinks to keep the "Rest" and "Admin" in the folder structure? Below is what I have. It works but doesn't keep the pattern I want (it works because of a default below the one I defined above)

<li>@Html.ActionLink("Burger Star", "Promotions", "AdminCommon", new { siteName="BurgerStar" }, null)</li>
有帮助吗?

解决方案

Use @RouteLink

@Html.RouteLink("Burger Star", "RestaurantCommon", new { siteName = "BurgerStar" })
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top