开发者

View all session in asp.net application

Can 开发者_高级运维I view all active session(s) in my ASP.NET application?


You could perform this in global.asax:

private static object _syncRoot = new object();
private static List<string> _activeSessions = new List<string>();
public static ReadOnlyCollection<string> ActiveSessions
{
    get
    {
        lock(_syncRoot)
        {
            return new ReadOnlyCollection<string>(_activeSessions);
        }
    }
}

protected void Session_Start(object sender, EventArgs e)
{
    lock(_syncRoot)
    {
        _activeSessions.Add(Session.SessionID);
    }
}

protected void Session_End(object sender, EventArgs e)
{
    lock(_syncRoot)
    {
        _activeSessions.Remove(Session.SessionID);
    }
}

and then use the ActiveSessions variable which will contain a list of all session ids.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜