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

后端 未结 9 1762
我寻月下人不归
我寻月下人不归 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

    I explicitly set the action name as "Action/". Seems a little like a hack but it's a quick fix.

    @Html.ActionLink("Link Name", "Action/", "Controller")
    
    0 讨论(0)
  • 2020-11-30 05:17

    I needed my menu links to be dynamic. Rather than implement a lot of extra code and routing for every single page I simple dispensed with the HTML helper.

    <a href="@(item.websiteBaseURL)/@(item.controller)/@(item.ViewName)">@item.MenuItemName</a>
    
    0 讨论(0)
  • 2020-11-30 05:21

    The problem is the built in methods take input from the URL you are currently on as well as what you supply. You could try this:

    <%= Html.ActionLink("LinkText", "Action", "Controller", new { id = ""}) %>
    

    That should manually wipe the id parameter.

    0 讨论(0)
提交回复
热议问题