I have an asp.net core 3.1 mvc project where I have a search page (view). I am persisting search, filter and sort criteria values via Session data. This works fine, and persists data correctly, but the querystring does not contain all the information I need it to.
Values for the filters and search are selected via a form, and submit button, but sorting is selected by clicking the column headers in the search results. e.g.:
<form asp-controller="Companies" asp-action="Index" method="get">
<p>
<label>Company Name: </label>
<select asp-for="CompanyName" asp-items="Model.CompanyName">
<option value="">All</option>
</select>
<input type="submit" value="Find" />
</p>
</form>
<table class="table">
<thead>
<tr>
<th>
<a asp-action="Index" asp-route-sortOrder="CompanyName">@Html.DisplayNameFor(model => model.CompaniesListViewModelList[0].CompanyName)</a>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.CompaniesListViewModelList)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CompanyName)
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>
If the clicks in the header to change the sort order, none of the querystring values for the filters etc appear in the querystring.
The reason I need this is so that a link can be sent to someone else.
So the question is, how do I get all the used querystring values to appear in the querystring?
