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

  • Thread starter Thread starter Chris Cauchi
  • Start date Start date
C

Chris Cauchi

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
 
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
 
Back
Top