Groups | Blog | Home
all groups > asp.net > february 2007 >

asp.net : How to find out all active sessions in the asp.net web server??


Krish...........
2/15/2007 9:57:05 PM
Hi all,

How to find out no of active sessions (at a time) in the web
server.. I dont think handling Session_start and Session_end events
are useful for this. Is there any way to find all current active
sessions by using Application object ?

Thanx,
Krish....
Alexey Smirnov
2/16/2007 12:41:28 AM
[quoted text, click to view]


It can be done via Application level object/collection, each of the
session objects can be counted on Session_OnStart and deleted on
Session_OnEnd. However, Session_OnEnd is unreliable and this approach
(if with no any additional logic, e.g. checking the time expired)
could give you wrong number of session. Because of this, and if you
need to be more accurate, you can add the new sessions in the database
table (sessionID and time) and query this table.
Milosz Skalecki [MCAD]
2/16/2007 3:56:00 AM
Good morning,

In addition to Alexey's reply, if you already use SQL server ession state,
it's very easy to count sessions (see my reply in this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.framework.aspnet&mid=e97b7be9-94d5-4a61-8fa3-33a9fb4036f9).
Otherwise (in/out-process session management), you have to stick to session
logging in database as Alexey pointed out.
--
Milosz


[quoted text, click to view]
AddThis Social Bookmark Button