R – ASP MVC storing page states for later restoring

asp.net-mvccontrolsstates

I have a fairly complex ASP MVC set of controls that set a data filter (account ID range, cost range, carrier, dates etc). This also creates a data table object with the standard result set type object.

The user might wonder away from the page and then come back. I want to restore the previous filter control states and also pull the current result set.

What is the standard ASP MVC method for storing the user session state? I do have access to a SQLServer database. One idea is to store the filter view object and current result in the cache.

I do not need to restore the state between session visits (they close the browser and come back at another time.)

Best Answer

Storing Session State is the right key word.

http://msdn.microsoft.com/en-us/library/ms972429.aspx

http://www.devarticles.com/c/a/ASP/Maintaining-Session-State-With-ASP/

You need to simply grab the session state variable and store it somehow, then retreive it somehow. That might be a lot of work, and there might be a built in way to make it happen since you have an MS SQL Server right there. But I dont know about hooking those things up, so I'd write the session object to an objectstream hooked into the database. You can query for it later.

EDIT: On the other hand, since you said you don't need it to be restored between visits, maybe you just want to make the lease duration of this one a lot longer than it is. Sounds like they are timing out? Tell it to hang onto connections for a few more hours. Unless they close the page, theyll get a new logon at the front if the browser deleted cookies.

Related Topic