Storing address in the session

atmosphere1212

Freshman
Joined
Aug 31, 2004
Messages
42
Hey

I want to store the address of an object in the session and then recreate the reference later on by the address. Is this possible?

The reason im not storing the object in the session is because the object is large and i dont want to serialize it (the session is InProc). The object is also only going to be used during the current postback so i dont have to worry about the address pointing to the wrong object.
 
What is the object in question and what data does it hold that makes it so large? If it is only used in the current postback why do you need to persist it between postbacks?
 
PlausiblyDamp said:
What is the object in question and what data does it hold that makes it so large? If it is only used in the current postback why do you need to persist it between postbacks?

The object in question is a ControlCollection.

I dont need to persist it between postbacks, just between different controls and modules in the same post back.
 
If you need to reference the ControlCollection in methods, I'd reccomend passing an instance of the ControlCollection directly via one of the method's parameters. Or is this not feasible for some reason?
 
Bucky said:
If you need to reference the ControlCollection in methods, I'd reccomend passing an instance of the ControlCollection directly via one of the method's parameters. Or is this not feasible for some reason?

Its really not. I am creating a global interface to a set of dynamically created controls on the page that any class can access.

What about if I made a hash map in the global.asx file which would be indexed by a users session id, and would store the control collection during the current postback (and would be removed on prerender)

do you see any problems with this?
 
Anything you put in the session will survive for 20 minutes by default and is designed to maintain state between postbacks.
If you do not require the object to persist over postbacks then there is no reason to use Sessions or any other form of state management - you could simply expose this collection as a property of the page / a shared class and allow access from multiple controls / modules.
You may want to search the internet for information of the Model / View / Control pattern as a source of one possible method.
 
PlausiblyDamp said:
Anything you put in the session will survive for 20 minutes by default and is designed to maintain state between postbacks.
If you do not require the object to persist over postbacks then there is no reason to use Sessions or any other form of state management - you could simply expose this collection as a property of the page / a shared class and allow access from multiple controls / modules.
You may want to search the internet for information of the Model / View / Control pattern as a source of one possible method.


Ok, if i were to just expose the control collection as a property and then access it globally, how would I get the instance of the page when im in some random class?
 
Back
Top