473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

maintaining session state of class objects in asp.net

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
Nov 19 '05 #1
2 1980
Chris wrote:
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/
Nov 19 '05 #2
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.

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Das | last post by:
Hi all, I'm using Asp.net. Within a form I have declared declared a public variable. When the form is loaded I set the property for the variable. but it doesn't maintain its state on postback. I...
2
by: adam | last post by:
Having spent nearly 2 years in win forms land the inevitable request came for me to "do some web pages". So being new to this bit of .net and having had a look around I can't see where the best...
3
by: MattC | last post by:
I have created a container class and instantiated it in one of my pages. I fill the object on page load when not on a postback. On a button click i want to do somethign with the values in that...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
5
by: sdettmers | last post by:
Hi, Database: SQL Server Session: SQL Server Language: C# Application: ASP.Net I have created a login page which attempts to retrieve the users record from the database and I...
4
by: Gary | last post by:
Hello, I have implemented SQL Server session state in my application however I am having some problems. Simple objects stored in Session state are fine and are handled by .NET, however when I...
1
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In...
4
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.