Session.Abandon-Session.Clear-Session.RemoveAll
System.Web.UI.Page.Session属性和System.Web.HttpContext.Session属性 都是System.Web.SessionState.HttpSessionState类
这三种方法都可以清除session.
Session.Clear()和Session.RemoveAll()是完全一样的,即Clears all values from the session-state item collection.
Session.RemoveAll()内部就是调用了Session.Clear()
源码
// System.Web.SessionState.HttpSessionState
/// <summary>Removes all keys and values from the session-state collection.</summary>
public void RemoveAll()
{
this.Clear();
}
以上两种方法和Session.Abandon()是有区别的。
以上两种方法,只是清空了键值集合,而Abandon是Ends the current session.意味着Session对象被销毁destroyed,当然其保存的键值集合也会同样消失...
InProc模式下abandon方法会引发Session_End事件
Once the Abandon method is called, the current session is no longer valid and a new session can be started. Abandon causes the End event to be raised. A new Start event will be raised on the next request.
Abandon方法调用后,不是马上销毁,而是等待剩下的脚本执行完毕,因此仍在在随后的代码中被访问,但是本次请求完毕,随后的请求就无法继续访问到了
When the Abandon method is called, the current Session object is queued for deletion but is not actually deleted until all of the script commands on the current page have been processed. This means that you can access variables stored in the Session object on the same page as the call to theAbandon method but not in any subsequent Web pages.
<%
Session.Abandon
Session("MyName") = "Mary"
Reponse.Write(Session("MyName")) //本次请求仍然有值
%>
新的请求将会创建新的Session对象,虽然仍然存储相同的键值,例如
Session("MyName") = "Mary" ;
,但是这个Session已经是新对象了
另外,如果inproc模式下,设置的时间超时,会自动调用Abandon方法
The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandonmethod explicitly, the server destroys these objects when the session times out.
https://msdn.microsoft.com/en-us/library/ms524310(v=vs.90).aspx
Session.Abandon-Session.Clear-Session.RemoveAll的更多相关文章
- Session.Abandon, Session.Clear和Session.Remove的区别
Session.Clear()就是把Session对象中的所有项目都删除了, Session对象里面啥都没有.但是Session对象还保留. Session.Abandon()就是把当前Session ...
- Session.Abandon和Session.Clear的实现和区别
我在网上找了一个比较贴切的描述: Session.Clear()就是把Session对象中的所有项目都删除了,Session对象里面啥都没有.但是Session对象还保留.Session.Abando ...
- Session.Abandon和Session.Clear有何不同 (转)
Session.Clear()就是把Session对象中的所有项目都删除了, Session对象里面啥都没有.但是Session对象还保留.Session.Abandon()就是把当前Session对 ...
- Session.Abandon与Session.Clear之间的区别
Session.Clear()就是把Session对象中的所有项目都删除了,Session对象里面什么都没有.但是Session对象还保留. Session.Abandon()就是把当前Session ...
- HttpContext.Current.Session.Abandon() 大坑 要注意
HttpContext.Current.Session.Abandon(); 如果在调用以上代码之后再存储session 在当前上下文之内是可以访问session的.. 但是页面跳转之后..在其他页面 ...
- Hibernate之Session缓存以及操作Session缓存的相关方法
1.Session概述 A.Session 接口是 Hibernate 向应用程序提供的操纵数据库的最主要的接口, 它提供了基本的保存, 更新, 删除和加载 Java 对象的方法. B. Sessio ...
- 六十一:Flask.Session之flask操作session
1.设置session:使用flask.session就可以操作字典,操作方式和操作字典一样:session['key']=value2.获取session,和获取字典的值一样:session['ke ...
- Django(十三)状态保持 —— cookie与session+ajax异步请求+session记住登录状态+cookie记住登录名密码
一.状态保持的概述 http协议是无状态的.下一次去访问一个页面时并不知道上一次对这个页面做了什么.因此引入了cookie.session两种方式来配合解决此问题. Duplicate entry:重 ...
- 懒加载session 无法打开 no session or session was closed 解决办法(完美解决)
首先说明一下,hibernate的延迟加载特性(lazy).所谓的延迟加载就是当真正需要查询数据时才执行数据加载操作.因为hibernate当中支持实体对象,外键会与实体对象关联起来.如 ...
- 【荐】PHP Session和Cookie,Session阻塞,Session垃圾回收,Redis共享Session,不推荐Memcached保存Session
什么是 Session 在 web 应用开发中,Session 被称为会话.主要被用于保存某个访问者的数据. 由于 HTTP 无状态的特点,服务端是不会记住客户端的,对服务端来说,每一个请求都是全新的 ...
随机推荐
- 调试VBA程序常用方法
在中断模式下(ctrl+Break键),可以做: 1.执行 工具----选项----编辑器----勾选“自动显示数据提示” 则当用鼠标悬停在变量或表达式上时,会出现提示窗口,显示其名称和值! 2 ...
- mysql链接出现10060
http://www.cnblogs.com/meetrice/p/5309666.html 使用navicate链接 http://www.cnblogs.com/cxint/p/7454054.h ...
- (转)winform下TCP通信的简单应用
本文转载自:http://blog.csdn.net/wanlong360599336/article/details/7557064 先看效果图: TCP比较繁琐的就是三次握手定理,每次再发送数据前 ...
- android开源库收集
1. google valley Android网络通信库 git clone https://android.googlesource.com/platform/frameworks/volley ...
- 杂项-WiFi:JotSpot
ylbtech-杂项-WiFi:JotSpot JotSpot公司成立于2003年,由曾经创建了搜索引擎Excite的Joe Kraus一手创建,曾获得了来自Mayfield和RedPoint 两家风 ...
- Java-Maven-Runoob:Maven IntelliJ
ylbtech-Java-Maven-Runoob:Maven IntelliJ 1.返回顶部 1. Maven IntelliJ IntelliJ IDEA 已经内建了对 Maven 的支持.我们在 ...
- 《拳皇98终极之战OL》系统分析
转自:http://www.gameres.com/467959.html 游戏简述 <拳皇98终极之战OL>是由日本SNK官方正版授权,国内著名游戏公司北京掌趣科技与北京玩蟹科技开发,腾 ...
- 010. windows10下安装kivy 1.9.1版
Microsoft Windows [版本 10.0.14393] 以管理员权限打开cmd (c) 2016 Microsoft Corporation. 保留所有权利. 1. C:\Users\LG ...
- MFC学习(七) 单文档程序
1 MFC单文档程序的主要类 (1)文档类(Document) 即应用程序处理的数据对象,文档一般从 MFC 中 CDocument 中派生.CDocument 类用于相应数据文件的读取以及存储 Cv ...
- C# 面向切面编程--监控日志记录方案
背景:现在公司整体在做监控平台,要求把各个部分的细节都记录下来,在前台页面上有所显示,所以现在需要做的就是一个监控日志的记录工作,今天讲的就是渲染监控日志的例子. 现状:当前的渲染程序没有为监控日志记 ...