积极答复者
如何通过sessionState mode="InProc"来触发session_end事件

问题
-
答案
-
你好,
据我所知,这个事件的触发条件是当请求触发HttpSessionState.Abandon事件或者当session过期的时候。
什么算session过期呢。
Session有一个TimeOut属性,默认是20分钟,当session过期的时候才会触发session end事件。
具体的话你可以参照MSDN的官方说明:
https://msdn.microsoft.com/zh-cn/library/system.web.sessionstate.sessionstatemodule.end(v=vs.110).aspx
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已编辑 Brando Zhang 2017年12月1日 2:10
- 已标记为答案 流星枪 2017年12月2日 5:53
-
你好,
请问你的需求是想要再浏览器关闭的时候直接触发HttpSessionState.Abandon方法然后触发Session_End事件?
能告诉我在Session_End事件里面写了什么代码吗?
这样我就可以考虑给你一个比较合理的建议。
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已标记为答案 流星枪 2017年12月12日 3:10
全部回复
-
你好,
据我所知,这个事件的触发条件是当请求触发HttpSessionState.Abandon事件或者当session过期的时候。
什么算session过期呢。
Session有一个TimeOut属性,默认是20分钟,当session过期的时候才会触发session end事件。
具体的话你可以参照MSDN的官方说明:
https://msdn.microsoft.com/zh-cn/library/system.web.sessionstate.sessionstatemodule.end(v=vs.110).aspx
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已编辑 Brando Zhang 2017年12月1日 2:10
- 已标记为答案 流星枪 2017年12月2日 5:53
-
你好,
请问你的需求是想要再浏览器关闭的时候直接触发HttpSessionState.Abandon方法然后触发Session_End事件?
能告诉我在Session_End事件里面写了什么代码吗?
这样我就可以考虑给你一个比较合理的建议。
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已标记为答案 流星枪 2017年12月12日 3:10
-
你好,
如果你想实现关闭浏览器关闭session,你可以考虑使用AJAX也可以考虑再弹一个子页面,子页面里面有关闭session的事件.
具体实现方法可以这样,使用JavaScript在浏览器检测关闭事件。
然后使用ajax发送请求到后台call后台的webmethod。
在这个webmethod中写代码使在线人数减一。
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.