Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How can i subtract the number of current users as soon as i close the browser. I chkd on google but it says that there is no event handler for that...What should i do. Please Help....
Posted 31-Dec-10 21:17pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You Can Use Session_Start to Increase number of users and
Session_End Event to decrease the number of user in Global.asax (Global.asax.vb) file in ASP.net
 
If you don't have this file in your project you can add it using Add New Item - Global Application Class
 
Here is sample Event for your Global.asax.vb file
 
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
       ' Code that runs when a new session is started
   End Sub
 
   Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
       ' Code that runs when a session ends.
       ' Note: The Session_End event is raised only when the sessionstate mode
       ' is set to InProc in the Web.config file. If session mode is set to StateServer
       ' or SQLServer, the event is not raised.
   End Sub
 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here you go
 
^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

The short answer is there is no reliable way. Sessions are handled server side, not client (browser) side.
 
An unreliable method is to handle the onunload event in javascript and fire back an Ajax call that would inform the server that the browser is closing. This won't work if javascript isn't enabled, if there is a network problem, or if the browser is killed before it gets a chance to send the request.
 
The correc thing to do is ask yourself: what are you trying to achieve?
  Permalink  

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

  Print Answers RSS
0 mhegazy94 460
1 Sergey Alexandrovich Kryukov 405
2 Kornfeld Eliyahu Peter 275
3 Gihan Liyanage 163
4 Sibeesh KV 156
0 Sergey Alexandrovich Kryukov 6,775
1 OriginalGriff 6,696
2 CPallini 5,345
3 George Jonsson 3,599
4 Gihan Liyanage 2,751


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 3 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100