Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
VB
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.
Posted

1 solution

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

Event global.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
 
Share this answer
 
v2
Comments
Espen Harlinn 7-Nov-11 11:24am    
Good points :)
RaisKazi 7-Nov-11 11:29am    
Thank you Espen. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900