Counting active users when using sessionState mode=StateServer ?

Counting active users when using sessionState mode=StateServer ?

am 24.04.2008 22:34:58 von Bjorn Sagbakken

The subject says it all, more or less.
With sessionState mode=InProc in web.config this works fine, using this
approach in the global.asax:

In the session_start event the count up:

In the session_end event the count down:

However, with sessionState mode=StateServer, the session_end does not fire,
so a workaround has to be appended.
I just haven't found the best approach yet. I have tried one suggestion,
where another event was added to the global.asax
(Application_PreRequestHandlerExecute) where the reading of the current
userID stored in a session var was a part of the idea. However, I got an
error message, saying the "session is not available...." or something like
that. Then I tried to implement a needed Http module in the web.config for
this, but obviously I got rather lost with other error messages about wrong

So, before I stumble more in half blindness, I would be happy for any
pointing directive.