Last post Jun 18, 2016 07:45 AM by Chris Zhao
Jun 09, 2016 06:15 AM|ArunCode47|LINK
In my asp.net application after I login, my session variables, which I set in login page, are getting lost after the call to Response.Redirect method.
After googling I found the below link elaborate the cause of the problem.
I really couldn't get the solution suggested in the above link.
I didn't get the error or the issue was not there for a month. It suddenly appeared yesterday and I'm unable to use my session variables if use Response.Redirect method, even with the second argument with 'false', ie. Response.Redirect(URL,false);
Why I got the error all of a sudden? And what is the solution?
Jun 09, 2016 08:09 AM|Zhi Lv - MSFT|LINK
According to your description, I create a sample on my side, it seems that everything works well.
I suggest you could refer to the following link:
A number of things can cause session state to mysteriously disappear.
Besides, I suggest you check the Session State Mode. You can use StateServer or SqlServer session state mode.
Jun 09, 2016 09:20 AM|ArunCode47|LINK
Thanks Zhi Lv,
Suggestion are telling about losing session after leaving the application ideally for quite long time.
But in my case I'm unable to carry a session variable from the login page itself and want to use it in the next page.
If I use Response.Redirect method with single argument(URL), I'm getting below exception and my session variables are lost.
"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"
If I use Response.Redirect() with 2nd argument as 'false', I'm not getting any exception, but my session variables are lost.
Any way my session variables are getting lost. And this is happening all of a sudden. Untill yesterday afternoon application was working fine. I didn't do any change in web.config file or IIS server.
Jun 10, 2016 10:02 AM|Zhi Lv - MSFT|LINK
For the second argument, you can refer to this article:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"
As for this issue, you can check this link:
Jun 10, 2016 11:14 AM|ArunCode47|LINK
If I use Response.Redirect() with 2nd argument as 'false', I'm not getting the above mentioned exception, but my session variables are lost.
I want to carry the session variable and also use the redirect method.
This error occurs in my test instance, but in my production instance, I'm able to get session variables even if i use Response.Redirect() method.
What could be the possible reason for this issue???????
Jun 18, 2016 07:45 AM|Chris Zhao|LINK
Have you tried setting cookieless="true" in web.config? Check that enableSessionState hasn't been set to false in the web.config.
<system.web> <pages enableSessionState="true">
ASP.NET Session State Overview