开发者

How can I change the ActionLink behavior?

开发者 https://www.devze.com 2023-01-18 11:18 出处:网络
Been new to MVC 2, how can we get a link as: http://localhost:13269/Terms instead http://localhost:13269/Frontend/Terms

Been new to MVC 2, how can we get a link as:

http://localhost:13269/Terms

instead

http://localhost:13269/Frontend/Terms

as this is the result of:

<%: Html.ActionLink("Terms & Conditions", "Terms", "Frontpage")%>

even if I don't specify the Controller like <%: Html.ActionLink("Terms & Conditions", "Terms")%>

as I changed the route to

r开发者_运维技巧outes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Frontend", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);


Try this as a new route definition (declare this before the default route)

routes.MapRoute(
    "DefaultFontEnd", // Route name
    "{action}/{id}", // URL with parameters
    new { controller = "Frontend", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
0

精彩评论

暂无评论...
验证码 换一张
取 消