Use @RouteLink
@Html.RouteLink("Burger Star", "RestaurantCommon", new { siteName = "BurgerStar" })
Pergunta
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>
Solução
Use @RouteLink
@Html.RouteLink("Burger Star", "RestaurantCommon", new { siteName = "BurgerStar" })