maintaining session state of class objects in asp.net

G

Guest

Hi,

I am building a single webform/webpage asp.net application using VB.NET.

I have created lots of classes for this web application.
On page load I use a facade controller pattern class to perform all my initial
class object instaniations using sub new() procedures

I'm using this project to learn the ins and outs of OOA and OOD, so instead
of doing everything in code behind pages I have lots of objects now created
with lots of properties.

My strategy for instance is to have objects with properties contain the
values of the currently selected web form object values (i.e. currently
selected item in list box) in
properites for an object instead of using the other method of simply reading
the value straight from the web object.

I am trying to keep business logic out of the interface object.

I don't know how to save my "session" objects so that when I click on a a
server side web interface object (ie. dropdown list box) I can save the new
selection to my object and not to code behind page objects.

Do I use session values the whole time, or view states, or cookies?
There would be an extra layer of extracting values if this is done:
1 create objects with initial properties.
2.put all my properties into session state value
3.interact with form, change session state values
4. recreate my object with a sub new procedure and pass all my session data
back into the object?

this seems like no return on investment architecturally or performance wise.

Can I save entire instantiated classes (objects) into a session variable?
If so , is this my answer?

thanks

Chris
 
G

Guest

Chris said:
Can I save entire instantiated classes (objects) into a session variable?
If so , is this my answer?

Yes you can. However, you should be careful about what you store in the
session state because storing large objects in session state can
seriously degrade performance.
By default, the controls save their state in the Viewstate object. This
object is serialized to a text string and included in the HTML output.
When the page is posted back the control restore their state from the
Viewstate. If you have a class which abstracts the selected value, you
should set the values of this object on each post back. You can do this
in the Load event.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
K

Kevin Spencer

A word about architecture:

My uncle is an architect, not of software, but of buildings. He spent 6
years learning architecture, getting his degree, and qualifying for his
license. Most of those 6 years were NOT spent in studying how, for example,
Frank Lloyd Wright defied the laws of gravity when he designed the
Guggenheim museum in NYC. Most of those 6 years were spent in learning
fundamentals. What is a hammer? What is a nail? What is a 2X4? What sort of
materials are best for putting weight stress upon? What sort of materials
have high tensile strength? What is a dove-tail joint? What math is used to
calculate the number and height of stairs required to go from the first to
the second floor of a building with 10-foot ceilings?

In other words, architecture is the sum total of all knowledge used to build
things. An architect can design a skyscraper, or he can detail the carving
needed to restore the handrail of an antique stairway. Heck, he can do the
carving himself if he needs to.

Big things are made up of lots of little things. Watch your pennies, and the
dollars will look after themselves. I would advise concentrating on the
details. If all the details are right, the whole will be right.

Big architectural concepts are naturally derived from small principles.
Master the small stuff first. Once you do, the big stuff will be obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top