At a lot of places I have seen the following pattern. Consider the code:
Customer cust = (Customer) Session["Customer"];
//Do something to the object cust
Session["Customer"] = cust
and the code :
Customer cust = (Customer) Cache["Customer"];
//do something to object cust
Cache["Customer"] = cust;
Now, in the second case, putting the cust object back to Cache is not required as the reference is the same and any changes to the cust object shall be reflected in the cache.
But I dont think that is the case in case of Session, where the cust object has to be explicitly put back into the Session. However, I am not sure. Will the change reflect in Session if I do not explicitly specify the change as above?
And if it needs to be done explicitly, why the difference in behavior with Cache object? Both places we seem to be doing a reference passing.
This is for C#, ASP.NET