NOTE: All of the code here is paraphrased as an example, as I can\'t show real code.
I have a view model class that looks something like
<
A RedirectToAction is simply a HTTP 302 redirect. Are you sure you need the browser to re-request a new page?
For instance do you want to avoid a page reload from triggerring a "resubmit post data" dialog? (see POST-REDIRECT-GET pattern)
Why not just use:
public ActionResult Filter(FormCollection formParams)
{
return Search(new SearchViewModel{
Term = formParams["Term"],
Filters =
formParams.Keys
.Cast()
.Where(k => k.Contains("filter"))
.Select(k => Filter.Build(k, formParams[k]))
.ToList()
});
}
Alternatively you could use TempData to store the state between requests, or possibly client side cookies if suitable.
If you want the Search results page to be bookmarkable in a users browser you'll need to represent the search parameter's state in the URL using REST or some form of serilaised string (eg. JSON)