i have a class. within the constructor for this class it tests if 2
session objects exist and if they dont it creates them. this is a one
off deal. The session objects are both Hashtables.
afterwards the class is reinstantiated on a different page. i am then
calling a method on this class. I basically want to retrieve one of
the Hashtables from the session, clear it, then add a key/value to
it. But for some reason i cant understand it is clearing and adding
values to BOTH my in session Hashtables instead of just one.
here is the relevant code:
// constructor
public SessionHandler()
{
if (HttpContext.Current.Session["ClientPortfolio"] == null)
{
Hashtable htC = new Hashtable();
Save(htC, "ClientPortfolio");
}
if (HttpContext.Current.Session["MatterPortfolio"] == null)
{
Hashtable htM = new Hashtable();
Save(htM, "MatterPortfolio");
}
}
// method
public void InitClientPortfolio(string clientCode, string clientName)
{
Hashtable ht = (Hashtable)
HttpContext.Current.Session["ClientPortfolio"];
ht.Clear();
ht.Add("ClientCode", clientCode);
ht.Add("ClientName", clientName);
// **** These 3 methods have affected the Hashtables for both
"MatterPortfolio" and "ClientPortfolio"??? Why and how can I fix
please?
}