views:

1370

answers:

1

Say I have the following situation:

  • A paginated View displays a list of contacts with the following route: Contacts/Index/Page/2.
  • The View gets its paginated data ViewModel object.
  • The View also gets its filter properties from the ViewModel, like the Contact Category.

I would like to store the page number and the filter properties somewhere in such a way that when the user returns to Contacts/Index page, the same page number and filters are applied.

Is it good practice to store these properties within a Session variable? Should the ViewModel be handling these Session variables?

Is there another way to tackle this type of situation?

+2  A: 

if you want to have the same filters/page after you have returned from another page back, then you must use session, there is no other better way

Omu
It looks like the user who asked this question is no longer a member of the site.
Dan Atkinson
This is how I had to accomplish the same thing. User performs a search, then edits one of the items from the search, possibly a sequence of multiple pages, and in the end must be returned the original search results. Session variable for the win.
Ogre Psalm33