Last post Sep 23, 2011 04:53 PM by prabodhm
Jul 25, 2011 06:54 PM|jbonds|LINK
Say a user has 2 instances of the same page open and they're working in both pages at once. Both pages cannot access the same session Key (i.e. Session("myData") as one will overwrite the other. The method that I'm thinking about using involves the use of a
GUID generated when the pages is loaded and stored in a hidden variable on the page and then appended to the Session key as such:
Session(PageGUID & "myData")
This guarantees that both pages will have their own little copy of whatever data is needed...
I'm worried about memory leaks. Doesn't using this technique basically grow the session each time the page gets accessed? Is there any way to somehow manage the session so that the memory gets dumped when it is no longer needed? Is there a better way to
Jul 25, 2011 09:47 PM|suresh_g_v2002|LINK
If the value strored is used only for that particular page.., then use ViewState instead of Session.., this avoids the overwrite issue
Jul 26, 2011 11:19 AM|jbonds|LINK
The only problem with this is that the entire viewstate gets sent back and forth with each partial postback when using Ajax. I think that for scalability, this really may be the only good option as long as the objects are small. Tis a difficult balance.
Sep 23, 2011 04:53 PM|prabodhm|LINK
storing the data in viewstate might not harm you, if the data is resonably sized.
If you are worried about the bytes send across the wire, you may save the Viewstate for that entire page in Session. ref:
The fails if you have a web farm / web garden scenario and session mode is set to inproc