简体   繁体   中英

Session variables are lost after server and/or client-side page redirect

Setup:

I have a landing page with a button on it. When the user clicks the button a postback occurs. In the click handler of the button I set a couple of session variables. Then I redirect the user to another page.

Problem:

When the other page loads, the SessionID is identical (the same session still exists), however, all the session variables have vanished. I have googled the problem extensively trying all the various solutions (and there are many) but none of them have worked for me.

I have tried:

Response.Redirect("NewPage.aspx", false);

I have also tried adding a meta refresh tag (dynamically) which side-steps any potential problems related to using Response.Redirect(...).

<meta http-equiv="refresh" content="0;URL=NewPage.aspx" />

In both of these cases the redirect succeeds but the session variables no longer exist. I have extensively checked all IIS settings, analyzed the data that is exchanged between browser and server, but all to no avail.

Additionally, two colleagues who work on the same project (with identically configured development machines) do not have this problem!

Question:

Is there a rational explanation for this problem or have I in some way insulted or offended my development PC and is it now taking revenge on me?

I recall seeing this issue happen when calling response.redirect() during an asynchronous post back. If you are using an UpdatePanel, try removing it to see if it solves the issue. If that is the problem, then I believe this has to do with a bug in an old version of the Ajax libraries. Since you haven't made any mention of version information, I think that this is a fair assumption.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM