Last post Sep 14, 2011 04:29 PM by bleroy
Sep 07, 2011 09:02 AM|labshasan|LINK
I have added two user object and then tried to store those in Session. I tried to get those from the sam aspx page first. It works fine there.
Then i tried to get that from another page using response.redirect. in that page i have used same code but it's (for List key) not giving same output, though for single "Name" key it's working well.
userObj = new HttpSessionStateSample.Entity.User();
pProvider = new
another page code:
name = HttpSessionStateSample.Utility.SessionManager.GetItemFromSession("Name").ToString();
profileList = Utility.SessionManager.GetProfileInfo();
Sep 07, 2011 11:22 AM|reza141414|LINK
use this way :
and restore the session value like this:
Sep 08, 2011 02:53 AM|labshasan|LINK
there is no problem with string type. problem is when i am stroing a list in Session. then after redirecting to another page i am loosing the list value stored in session from the previous page. i have searched for this and one hints got from many sites
that it may be a case of Response.Redirect. Some one suggested to use Server.Transfer. I have tried to use Server.Transfer but it's not give me permission to compile it well.
Sep 08, 2011 02:55 AM|bhagirath|LINK
Make sure your are redirecting on same server(URL).
Sep 08, 2011 03:39 AM|salman behera|LINK
get some idea here.....
Sep 08, 2011 05:47 AM|labshasan|LINK
I have added code like:
From the default page i have added two item in session - a string 'name', a list item 'profileinfo'.
at the default page it get the list value and string value, here the 'profileinfo' key displays item count = 2.
But when it redirects to 'WebProfile' page i get the two key item name - 'name' and 'profileinfo'. the 'name' key contains it's value but the 'profileinfo' key
displays item count = 0;
Sep 08, 2011 07:50 AM|labshasan|LINK
At last i have got one possible solution for my problem. What i have done is - i have taken the objects as static (1) and then comment out (2) the lines which was clearing the list items after inserting them into Session["PropertyInfo"].
pProvider = null;
I don't think this is the best or even the only solution. There may have some technical issues involved with such cases. Still looking
for the logic behind it, because the why commenting these lines displaying correct list items (count=2) in both of the pages.
Sep 14, 2011 04:29 PM|bleroy|LINK
Ouch. Using static variables is a big no-no and a sure way to run into thread safety issues. Session is designed to deal with this. Working around a problem by re-implementing the standard component is a very bad idea. Jsut use the overload to the redirect
API that doesn't terminate the thread.