Last post Dec 16, 2015 04:40 PM by ninianne98
Dec 16, 2015 02:50 PM|sridhar2000|LINK
I am in the process of developing an web application. One of the requirement is to maintain a DataTable till the execution of the page is complete, i.e., a datatable would be defined upon the page being loaded and subsequently data(rows) would be inserted
into the datatable based on user action and finally when the user clicks the save button, the datatable will be re-organised and saved to a database. To achieve this, I proposed to maintain the datatable in a session variable which will be defined when the
page is loaded. Any addition & changes will be saved to same session variable.
Now my question is:
1. Is this method viable?
2. I know that the session variable has time out value which is defined in the web.config, I would like to know if the timeout is calculated from the rendering of the page (i.e., loading for the first time) or from the last time the page was reloaded (i.e.,
3. Is there any other method through which this can be accomplished.
Thanks in advance.
Dec 16, 2015 04:40 PM|ninianne98|LINK
session is volatile, but it can be useful as a temporary short lived storage mechanism. look into SQL based session management
https://support.microsoft.com/en-us/kb/317604 . I've also experienced what I call "session burp" IIS cycles for some reason - memory, pool cycle time, idle state, in dev a recompile, etc and lost
work/had to start over.
Another way I've done temporary in-memory data is to serialize the entity and store in a temporary location in a SQL database where there is a row key identifying the user who is working with the data and each time the page loads, it queries that cache table
and rehydrates the entity from XML. This completely bypasses IIS session (you're kinda building your own), and only relies on the user being logged in in some fashion. Some mechanism to expire the data should be implemented, a date stamp and deletion or
overwrite if over a certain age or as part of the final save. See
https://github.com/ninianne98/CarrotCakeCMS/blob/master/CMSAdmin/c3-admin/CMS.asmx.cs and look at the attribute cmsAdminContent for ideas on serialize/deserialze. If you are using a DataSet, you don't even have to do XmlSerializer - you can do ds.GetXml()
/ doc.LoadXml(xmlString) loading.