I want use the Html.ActionLink which allows passing route values for name/value pairs used in the query string with a name that defined by a variable.

    var searchFieldName = ViewData["SearchFieldName"];
    var searchFieldValue = ViewData["SearchFieldValue"];
    string searchView = ViewData["ReturnSearchView"].ToString();

@Html.ActionLink("Search", searchView, new { searchFieldName = searchFieldValue });

I want searchFieldName to replaced with it's value, such as:

<a href="/search?somefield=value">

Instead the query string has "searchFieldName" as the name:

<a href="/search?searchFieldName=value">

How do I achieve the desired result?

Related posts

Recent Viewed