What I did for such cases, which I find simple but powerful, serializes my view model object for JSON (in your case, SearchViewModel ) using something like NewtonSoft JSON.net , then with the resulting JSON string, do a simple string compression using zlib.net Zlib.DeflateStream (you can also use something like AES Rijndael , but you will no doubt be slower and you want speed in the first place) and then pass the resulting Base64 string to your QueryString.
Then, when you are ready to use it again (it is effectively a viewstate), just unzip the JSON string and deserialize it from JSON to the appropriate .NET object (again in your case, SearchViewModel ).
Worked for me, and you are not getting a URL that is an unmanaged or some real measurable performance impact that I saw when only a few form fields were serialized.
I will develop the code soon.
UPDATE: code examples ...
This is what I would do in your specific scenario:
In Results(string, SearchViewModel) action:
public ActionResult Results(string encryptedUrlViewModel, string game, SearchViewModel vm) { SearchViewModel searchUrlViewModel = null; if (!string.IsNullOrEmpty(searchUrl)) {
In sight:
@Html.PagedListPager((IPagedList)Model, page => Url.Action("Results", new { encryptedUrlViewModel = ViewBag.EncryptedUrlViewModel }))
The code may require some tweaks not verified in your script, but it will be something like this, good luck :)
You really have to keep in mind that if you want to carry a custom request in a URL through paging, then you might think why the form was not made as a GET request, and not a POST request in the first place. Any reason you especially wanted this POST ? I think GET will correctly migrate your Colors array, but make sure your view model is set up correctly. See the Haacked article for linking a model to lists .