当Session.Abandon()无法正常工作时,如何以编程方式结束asp.net中的会话? [英] How do you programmatically end a session in asp.net when Session.Abandon() doesn't work?
问题描述
Session.Abandon()似乎什么也没做.您可能希望在调用Session.Abandon()时触发Session_end事件.
Session.Abandon() doesn't seem to do anything. You would expect the Session_end event to fire when Session.Abandon() is called.
推荐答案
这很可能是因为您的SessionMode
不是 InProc
(唯一可以检测会话何时结束的人)
This is most likely because your SessionMode
is not InProc
(the only one that can detect when a session ends).
引自 MSDN :
会话事件
ASP.NET提供了两个事件,可以帮助 您可以管理用户会话.这 当 新的会话开始, 当 会话被放弃或过期. 会话事件在 ASP.NET的Global.asax文件 应用程序.
ASP.NET provides two events that help you manage user sessions. The Session_OnStart event is raised when a new session starts, and the Session_OnEnd event is raised when a session is abandoned or expires. Session events are specified in the Global.asax file for an ASP.NET application.
Session_OnEnd事件不是 如果会话模式属性,则支持 设置为InProc以外的其他值, 这是默认模式.
The Session_OnEnd event is not supported if the session Mode property is set to a value other than InProc, which is the default mode.
这篇关于当Session.Abandon()无法正常工作时,如何以编程方式结束asp.net中的会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!