Re: Some basic session state questions
- From: Hans Kesting <news.2.hansdk@xxxxxxxxxxxxxxx>
- Date: Mon, 10 Apr 2006 10:12:25 +0200
Hi,
My understanding is that session info must be stored using
Session["var"], which means text data. What I'd like to be able to do,
is keep an object alive throughout a user's session, without having to
serialize my data into text, save it as Session["var"], and restore it
using Session["var"] every time the user moves to a different page.
Is there no way to have a session *object* stay in memory and preserve
variable state without serialize/deserialize/Session[] ?
Thanks in advance
In Session you store *objects* (or rather: *references* to objects), not just strings. So you can store any object there without (de)serialization. That is, if you use "InProc" sessions. When you use StateServer or SqlServer to store session data, then the object needs to be serializable, but you don't have to do it yourself.
When you retrieve the object from Session, you have to cast is to the correct type.
MyObject obj = new MyObject();
Session["mine"] = obj;
....
MyObject obj2 = (MyObject)Session["mine"];
By the way, there is also a microsoft.public.dotnet.framework.aspnet newsgroup...
Hans Kesting
.
- References:
- Some basic session state questions
- From: codegreen9
- Some basic session state questions
- Prev by Date: Re: Cancel a pending async operation?
- Next by Date: Re: Retrieve the selected folder and entered file name from SaveFileDialog
- Previous by thread: Some basic session state questions
- Next by thread: Re: Some basic session state questions
- Index(es):
Relevant Pages
|
Loading