1

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.

1
  • Is there an actual requirement that you can't show the rest of the search criteria in the url? If not just put it in the url (controller action). You'll notice that's how google, bing, yahoo etc. have solved this problem. Commented Sep 21, 2010 at 17:20

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

+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.
0

/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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.