asp.net mvc Html.ActionLink() keeping route value I don't want

后端 未结 9 1893
我寻月下人不归
我寻月下人不归 2020-11-30 04:34

I have the following ActionLink in my view

<%= Html.ActionLink(\"LinkText\", \"Action\", \"Controller\"); %>

and it creates the follo

9条回答
  •  一个人的身影
    2020-11-30 05:13

    It sounds like you need to register a second "Action Only" route and use Html.RouteLink(). First register a route like this in you application start up:

    routes.MapRoute("ActionOnly", "{controller}/{action}", 
       new { controller = "Home", action = "Index" } );
    

    Then instead of ActionLink to create those links use:

    Html.RouteLink("About","ActionOnly")
    

提交回复
热议问题