tags:

views:

46

answers:

2

I am implementing a complex search module with result page support paging. Most of examples provided just passes pagenumber as a parameter for the Index action, and the action uses the pagenumber to perform a query each time the user hit a different page number.

My problem is that my search take many many more criteria(more than 10 criterias) than just simple pagenumber. Therefore, I would like to preserve either search criteria or search result data after users' first submission, so that I only have to pass the pagenumber back and forth.

So I don't know which way is better: preserve search criterias, so every time when click to new page, call controller action do search again? Or preserve search result data, so application don't need query database again and again, but the data been preserved will big. If you have any idea, how to implement? Thanks in advence.

+3  A: 

Preserving the search criteria in the querystring is generally best. It will allow users to bookmark the search.

Preserving search result data brings up issues of potential stale data and consumes more resources server-side. This wouldn't work well with large data sets anyway, as you would only be selecting one page at a time, so caching in memory wouldn't help much when the user navigates to the next page.

RedFilter
+1 - I'd suggest you generate a unique key for each search, and store an object that contains all the search criteria in memory, or DB, with that unique key. then pass the unique key on the querystring.
dave thieben
A: 

/I'd suggest you generate a unique key for each search, and store an object that contains all the search criteria in memory, or DB, with that unique key. then pass the unique key on the querystring./

So your means, save search criteria with unique key in DB, anytime I need THE search result again(include change page index), get unique key from querystring, run query again. That your suggestion, right? Thank you very much for your advice. Very help.

guotianpei