Enabling all request parameters in Html.ActionLink
On my page I have
@using (Html.BeginForm("list", "menu", FormMethod.Get)) { <div> Show categories: @Html.DropDownList("groupName", (SelectList)ViewBag.groups) <input id="Submit1" type="submit" value="Show" /> </div> } As for the option that the user selects, I create a list, and the Querystring in my address will look like this:
localhost/menu/list?groupName=controlpanel My problem is that I am using HtmlActionLink, for example:
@Html.ActionLink("Title", "List", new { foo = item.foo}) As a result, I got the result:
localhost/menu/List?foo=123 instead:
localhost/menu/List?foo=123&groupName=controlpanel Am I missing something ??
To use ActionLink, you need to include all the parameters that you want to display in the query string. The easiest thing I think is to add the GroupName property to your model (or to the ViewBag, like your other sample). Then you can do this:
@Html.ActionLink("Title", "List", new { foo = item.foo, groupName = Model.GroupName })