How to protect session variables in this case?

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

Hi!

If i have an aspx page that sets a Session variable based on some input
fields and then, in Internet Explorer go to the File menu and open a new
window... the new window will be the same aspx same in the same session...
but it will overwrite the Session variable with the input made in new
window. So then if I go back to the old window and press save (have a save
button)... I will save the session Variable BUT with the values made from
the new window... that's really not good.

How do I prevent this?

I DO need session variables in my scenario so don't question that please.

best regards
/Lars
 
In Page_Load, if this is the first time page is loading, create a GUID, and
store it in viewstate. Then, store your actual value in session under the
key that is the GUID you generated earlier. Every time you need your session
variable, retrieve the GUID from viewstate, and use that as the key.

Each page should have its own viewstate, and thus it's own different GUID.
 
Back
Top