在模块中记录会话结束 [英] Record Session End in Module
问题描述
当用户通过关闭浏览器而不是使用模块实际注销结束浏览会话时,我想写到数据库.
我知道我可以使用global.asax Session_End事件来实现这一目标.但是,我想通过模块执行此操作.
使用
Hi,
I am wanting to write away to the db, when a user ends his browsing session by closing the browser instead of actually logging out using a module.
I know i could use the global.asax Session_End event to achieve this. I want however to do this via a module.
Using the
Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler context.AcquireRequestState, AddressOf app_AcquireRequestState
End Sub
Public Sub app_AcquireRequestState(ByVal o As Object, ByVal ea As EventArgs)
Dim httpApp As HttpApplication = CType(o, HttpApplication)
Dim ctx As HttpContext = HttpContext.Current
ctx.Response.Write(" Executing AcquireRequestState ")
End Sub
事件处理程序,我可以检查该会话是否处于活动状态或已终止,然后将其作为过期/关闭的浏览器注销将其写出吗?
我还有什么其他事情可以通过模块来实现吗?
任何帮助将不胜感激.
谢谢.
event handler, will i be able check whether the session is active or killed and then write it away as a expired/closed browser logout?
Is there any other event i could up to in the pipeline to achieve this via a module?
Any help would be appreciated.
Thanks.
推荐答案
好吧,您不能使用 HttpModule 执行此操作.从根本上来说,只要有新请求进入Web应用程序,就会调用HttpModule.
请查看下面的链接,以获取有关 HttpModule 和 HttpHandler 的更多信息.
本文详细介绍了HttpModule的所有事件.
http://www.15seconds.com/issue/020417.htm
如果您选择 OutProc 会话管理,则不支持事件global.asax Session_End
.
但是下面是一个CodeProject文章,对此有一个解决方法.
防止ASP.NET中的会话超时
但是,如果用户关闭浏览器,则以上文章无法为您提供帮助.为此,您可以看看下面的讨论.
http://forums.asp.net/p/1153888/1891072.aspx
Well you can not do this using HttpModule. Fundamentally HttpModule gets called whenever their is a new request comes to your Web-Application.
Have a look at below link for more information on HttpModule and HttpHandler.
This Article has details of all the Events of HttpModule.
http://www.15seconds.com/issue/020417.htm
Eventglobal.asax Session_End
will not support, if you go for OutProc Session Management.
However below is a CodeProject Article which has a work around for this.
Prevent Session Timeout in ASP.NET
But above article can not help you if User closes the Browser. For that you may have a look at below discussion.
http://forums.asp.net/p/1153888/1891072.aspx
这篇关于在模块中记录会话结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!