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?
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
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.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
2 Points
20 Posts
Session variables lost after the call of Response.Redirect method
Jun 09, 2016 06:15 AM|ArunCode47|LINK
Hi Everyone,
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.
http://weblogs.asp.net/bleroy/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_
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?
All-Star
45489 Points
7008 Posts
Microsoft
Re: Session variables lost after the call of Response.Redirect method
Jun 09, 2016 08:09 AM|Zhi Lv - MSFT|LINK
Hi ArunCode47,
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: http://stackoverflow.com/questions/3515947/losing-session-state
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.
https://support.microsoft.com/en-sg/kb/324772
Best regards,
Dillion
Member
2 Points
20 Posts
Re: Session variables lost after the call of Response.Redirect method
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.
All-Star
45489 Points
7008 Posts
Microsoft
Re: Session variables lost after the call of Response.Redirect method
Jun 10, 2016 10:02 AM|Zhi Lv - MSFT|LINK
Hi ArunCode47,
For the second argument, you can refer to this article:
https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx
As for this issue, you can check this link:
http://weblogs.asp.net/varadam/unable-to-evaluate-expression-because-the-code-is-optimized-or-a-native-frame-is-on-top-of-the-call-stack
Best regards,
Dillion
Member
2 Points
20 Posts
Re: Session variables lost after the call of Response.Redirect method
Jun 10, 2016 11:14 AM|ArunCode47|LINK
Hi Dillion,
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???????
All-Star
17652 Points
3510 Posts
Re: Session variables lost after the call of Response.Redirect method
Jun 18, 2016 07:45 AM|Chris Zhao|LINK
Hi ArunCode47,
Have you tried setting cookieless="true" in web.config? Check that enableSessionState hasn't been set to false in the web.config.
ASP.NET Session State Overview
Cookieless ASP.NET
Best Regards,
Chris