Can I modify ASP.NET session object this way?

asp.net

Solution

Asp.net Session will hold the reference, so you shouldn't need to do the following:

Session["CurrentEmp"] = oEmp;

after modifying oEmp;

Problem

Imagine that I have an instance (oEmp) of "Employee" class and I would like to store it session. ``` Session["CurrentEmp"] = oEmp; ``` If I modify a property in oEmp as follows: ``` oEmp.Ename = "Scott"; ``` Am I referring to session item through above statement or just only "oEmp"? ``` Session["CurrentEmp"] = oEmp; //Do we still need this after any property is modified ``` Is that the same case, if I opted for SQL Server session state (instead of InProc). thanks

Original source

Related problems