c# - Accessing properties of object stored in session -
i must misunderstanding session. i'm trying store information, let me give details.
here's "container" class holds list of business objects. container stored in session.
public class mysessioncontainer { private ilist<somebusinessobjecttype> _businessobjectlist = new list<somebusinessobjecttype>(); public ilist<somebusinessobjecttype> businessobjectlist { { return _businessobjectlist; } set { _businessobjectlist = value; } } }
i have set of pages form wizard/multi-step process, , need access list of business objects in container, in session.
the first page adds business objects list in session, sort of code used achieve that:
string key = getkeyforcurrentuser(); mysessioncontainer container = (mysessioncontainer) session[key]; somebusinessobjecttype businessobject = /* object view. */; container.businessobjectlist.add(businessobject);
the generated key same across pages.
however, when user gets second page, container in session expected list of business objects empty not expect. if first page adds business object, should there second , subsequent pages... right?
is there not understanding session in asp.net? why container in session not list? list not serialized container object when asp.net writes/reads session?
you need write session.
take @ example under session variables:
// when retrieving object session state, cast // appropriate type. arraylist stockpicks = (arraylist)session["stockpicks"]; // write modified stock picks list session state. session["stockpicks"] = stockpicks;
Comments
Post a Comment