I'm implementing a basic search feature for a site I'm working on. The cleanest way so far seems to be to create an action with a method signature similar to:
//
// GET: /BeautySchoolDropouts/Search?page=2&q=grease
public ActionResult Search(int? page, string q)
{
//Implementation
}
I have some code then on the search results page that provides the paging links similar to:
<%= Html.RouteLink("<< Previous Page", new { page = (Model.PageIndex - 1) }) %>
<%= Html.RouteLink("Next Page >>", new { page = (Model.PageIndex + 1) }) %>
Since I'm supplying the route values as part of the RouteLink
method, is it impossible to keep the q=whatever part of the querystring? Right now, the links generate /BeautySchoolDropouts/Search?page=2 only, which obviously causes issues because I have no idea what the search was for.