Persist object

G

Guest

Hello all,

I'm in need of some brainstormin help!

We have an object that we use in a number of places, both by User Controls
and Pages. This object is loaded everytime we need to use the piece of
functionality.

Example:

The user logs in and the object is loaded, the user then clicks a link to do
a task and again the object is loaded again.

What is the best way to persist the object? Session, cookie etc as it will
be used alot as the user uses the app.

Also, what are people thoughts about this, and it there any patterns that
may help?

Thanks all,

Jon
 
G

garethdjames

Some ramblings,

if the object is loaded from server side state then I suggest making
all your pages (and controls?) extend from a base class (that you
create), this class would extend from System.web.UI.Page,

This class could load the object and set a property, which the derived
classes could access.

If the object is not to big then I'd recomend doing this each page
load, caching the object brings in added complexity,

If its a big object (or static for all users) then cache it, use the
session for user based objects and cache for static objects

In my experience though its best to load the object with each page
request
 
E

Eliyahu Goldin

Jon,

If it is an aspx or html page and is called with the same parameters or
without any parameters, it will be cached on the client side and will open
very fast. You will have to tell us more about the nature of the object to
hear other suggestions.

Eliyahu
 
G

Guest

Eliyahu,

The object is data that is a collection class that we loop through to
create a tree (like Windows). This tree is not only used for navigation, but
also used in UserControls to help the user when carrying out some action,
like copying a file, specifying where to place a file etc.

The data help in the collection class rarely changes, but when we use it, we
always reload it and we were just thinking if that would be a performance
drag?

Thanks,

Jon
 
E

Eliyahu Goldin

Jon,

If the collection is specific to a user session, the best place is the
session.

If it is application-wide, meaning it is the same for all users, a public
static variable will be good. You can also use application's Cache if you
want to be able to control the way how the object persists.

Eliyahu
 

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

Top