ASP.NET MVC Storing Multiple Parameters Between Views

I have a very simple ASP.NET MVC site that displays images from a database. The user fills in some search parameters, and the view returns a list of images from the database that match the search criteria.

Now I add Pagination, where, depending on the page number, I skip a certain number of images retrieved from the database. This works for me for the first page. My search parameters are lost when I click on the second page of results, because I donโ€™t have a mechanism to store search parameters between views at the moment.

What is the best approach to take. I could have many search options. Should I store them all in a session or in hidden fields? It looks like a hack. Should I have a separate ViewModel to store the search parameters and save them in the session?

What is a typical approach?

+5
source share
2 answers

Usually you store cross-reference data in hidden fields. For scalability, sessions should be limited to session-related data. If you put data in hidden fields, a vulnerability opens up, you can consider serializing the view model and encrypting it as one hidden field. Putting it in a URL is another option, although you are limited by the amount of content you can post there.

+1
source

"" "". URL- .

+1

All Articles