我们在这里如何使用会话...? [英] How we use sessions here...?

查看:63
本文介绍了我们在这里如何使用会话...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击注销按钮时,我使用session.clear(),session.abandon()清除了所有会话值,但是我单击了中的后退按钮. INTERNETEXPLORER 它直接转到上一页.如何在asp.net,c#.net
中处理此类错误

when i clicked the logout button then i cleared all session value using session.clear(),session.abandon() but i clicked back button in INTERNETEXPLORER it directly go to previous pages.how to handle this type of error in asp.net,c#.net

Here how we use sessions..?

推荐答案

您可以在前面的页面中编写类似
的内容
You can write in the previous pages something like
if (Session["User"] == null)
Response.Redirect("sign-in.aspx");


检查会话是否已清除,或者在单击后退按钮时(如果会话计数为零,然后重定向到相应页面),请检查会话计数.
Check if the session cleared or not or check the session count when u clicking on back button if the session count is zero then redirect to corresponding page


我记得有这个问题,这是由仅IE导致的,因为使用后退按钮执行更改而不执行该页面,而是显示了该页面的最后一个缓存版本.我们的解决方法是像这样设置页面的缓存过期时间:

I remember having this problem, it''s caused by only IE for a change not executing the page on using the back button instead the last cached version of that page is displayed. our fix was to set the cache expiry of the page like this:

//NOTE: This is needed in conjunction with Session.Abandon() on logout or the back button click
//sends you straight back to the logged in view 
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();



希望对您有所帮助.



hope it helps.


这篇关于我们在这里如何使用会话...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆