Newbie question about Session and objects

G

Guest

If I am going to create an instance of an object and only use it in one place
(in a button click event handler), should I just create an instance of the
object in the handler and use it's method, or create it in the page_load and
put it into Session, retrieving it when the page loads each time?

The object does not retain any information, just performs a calculation and
returns the result.

What are the advantages of one over the other?

I could make this one method shared and not even have to create an instance
of the object, but would like to get an idea as to the mechanism of web pages
and objects.
 
G

Guest

I think it really boils down to "how expensive" is the particular operation.
If it is something like getting the same data out of a database every single
time, and its user-specific data, then I'd store it in session (or Cache, if
not user-specific) and check there first to get my "Stuff" before running the
operation, which would then store it in Session or Cache for repeated use.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top