By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

In session state, my object references are out of line. Why?

P: n/a
In my Global.asax Session_Start function I have the following:

TCustomer oCustomer = new TCustomer();
Session["FCurrentCustomer"] = oCustomer;

TCart oCart = new TCart();
oCart.Customer = oCustomer;
Session["FCurrentCart"] = oCart;

After the login page retrieves the customer info and populates the
FCurrentCustomer object, inspecting the FCurrentCart.Customer object
does not return the expected values. It's not a reference to the same
object anymore. Is this normal for ASP.NET?

I am new to ASP.NET, am used to the Windows programming world, so
please excuse my ignorance!

Chris Cauchi
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Chris--

This isn't a direct answer to your question: you should design this a
bit differently -- generally instantiating your objects at the session
level like this will cause a lot of headaches with scalability and
threading.

To keep it simple you could rework this logic into a user/server
control, a class in the DLL, etc...

Tom

ch*********@hotmail.com (Chris Cauchi) wrote in message news:<de**************************@posting.google. com>...
In my Global.asax Session_Start function I have the following:

TCustomer oCustomer = new TCustomer();
Session["FCurrentCustomer"] = oCustomer;

TCart oCart = new TCart();
oCart.Customer = oCustomer;
Session["FCurrentCart"] = oCart;

After the login page retrieves the customer info and populates the
FCurrentCustomer object, inspecting the FCurrentCart.Customer object
does not return the expected values. It's not a reference to the same
object anymore. Is this normal for ASP.NET?

I am new to ASP.NET, am used to the Windows programming world, so
please excuse my ignorance!

Chris Cauchi

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.