mvp - Asp.net,Session state issues with the following scenario -
can 1 me out of problem ,which facing sessions.
int a=5; httpcontext.current.session["session_variable"] = a; = 0; this exact problem facing. first assigning value 'a' session contains value 5. after make 'a' 0. in case value stored in session effected 0.
i tried iproc session outproc(sqlserver session),still issue exist.
thanks in advance adityap
the code showed in comments different code in question.
the code in question uses value type, assigning value variable session variable copy value. assigning value variable not affect value copied session variable.
the code in comments uses reference type, assigning value variable session variable copy reference. means both variable , session variable pointing same instance of object. also, code in comment changes member of object, doesn't assign new value variable.
when change member of object variable pointing to, change object session variable pointing because it's same object. it's not copy of object looks same, it's literally same object.
if want put object in session variable , able change object without affecting object session variable points to, need clone object , put copy in session variable. if object supports cloning can use clone method, otherwise need create instance of object has same values original.
Comments
Post a Comment