asp.netstateserver

How to find the Number of Active Users when using a StateServer


How can you find out the number of active users when you're using a StateServer? Also is it possible to query the StateServer and retrieve the contents in the Session State?

I know that this is all possible if you use SqlServer for a backing store, but I want them to be in memory.


Solution

  • Tracking the number of users would need to be done at the application level, not the session level.

    You should be able to see what is currently in the session with the following:

    StringBuilder builder = new StringBuilder();
    foreach ( String key in Session.Contents ) {
        builder.AppendFormat("{0}: {1}<br />", key, Session[key]);
    }
    Response.Write(builder.ToString());