C# 在Html.ActionLink中包含所有querystring参数

C# 在Html.ActionLink中包含所有querystring参数,c#,asp.net-mvc,asp.net-mvc-3,query-string,C#,Asp.net Mvc,Asp.net Mvc 3,Query String,在我的页面中,我有 @using (Html.BeginForm("list", "menu", FormMethod.Get)) { <div> Show categories: @Html.DropDownList("groupName", (SelectList)ViewBag.groups) <input id="Submit1" type="submit" value="S

在我的页面中,我有

 @using (Html.BeginForm("list", "menu", FormMethod.Get))
    {
        <div>
           Show categories:
            @Html.DropDownList("groupName", (SelectList)ViewBag.groups)
            <input id="Submit1" type="submit" value="Show" />
        </div>
    }
我的问题是当我使用HtmlActionLink时,例如:

@Html.ActionLink("Title", "List", new { foo = item.foo})
我得到的结果是:

localhost/menu/List?foo=123
而不是:

 localhost/menu/List?foo=123&groupName=controlpanel

我遗漏了什么吗?

这不是一个内置的解决方案,尽管它似乎正好满足了您的需求:


要使用ActionLink,您需要包括希望显示在查询字符串中的所有参数。我认为最简单的方法是在模型上(或像其他示例一样在ViewBag中)添加GroupName属性。然后你可以这样做:

@Html.ActionLink("Title", "List", new { foo = item.foo, groupName = Model.GroupName })

没错,但我想要一种处理多个querystring参数的通用方法。谢谢。这似乎是处理它的唯一方法。顺便说一句,我正在使用MvcPagedList,它足够聪明,可以在放置页面链接时执行同样的操作。
@Html.ActionLink("Title", "List", new { foo = item.foo, groupName = Model.GroupName })