Hello
First of all, sorry for my bad english ;)
I have a USER class that i create to every user that enters the website (not
neccesarily logged in). At the same time i insert it into a the
HttpRuntime.Cac he if it doesn't exist.
In every request i verify if the user is in the Cache so i don't have to
create it again. If it exists, i instantiate an USER object with the Cache
object already saved.
this is more or less the idea
string key="user"+Rand omValue;
if(HttpRuntime. Cache[key]==null)
{
Usuario miUser=new Usuario(); // by default, i initialize all private
fields in the constructor.
HttpRuntime.Cac he.Insert(key,m iUser,null,Date Time.Now.AddHou rs(1),TimeSpan. Zero);
miUser=Http.Run time.Cache[key];
}
else
{
Usuario miUser=Http.Run time.Cache[key];
}
My question is. If i change one private field value of my instance of the
USER class, will it be changed at the Cache object too? I think it does
'cause i'm referencing that object, not creating a new one (in the else
statement).
Is this OK or WRONG?
What i want is to keep the user object to keep its values along the
application life.
Saludos