开发者

How do I get a collection of Session State objects in ASP.NET?

How do I get the collection of all Session objects in ASP.NET? (Note that I am NOT looking for a collection of objects stored in the Session object but all of the session objects themselves.)

This is for an admin page that will list all active sessions and if the user is logged in will also list the user name etc.

Language: C# Framework: ASP.NET MVC 1.0 (3.5 SP1)

EDIT: A couple of good answers so far with a solution that I had thought of but not mentioned in my original question which is to add and remove the session objects in session_onStart and session_onEnd. The reason that I haven't done this yet is that I find it hard to believe that the collection of Session objects is not exposed to us. I am guessing开发者_如何学JAVA that ASP.NET stores this collection of Session objections in a collection of some type so I'm trying to find out how to get hold of that collection. I am happy to write the extra code to manage it myself but am not a fan of creating extra overhead and code to maintain if this functionality already exists.


you can use global asax and following methods.

sub session_onStart() 

    application.lock() 
    // your logic
    application.unlock() 

end sub 

sub session_onEnd() 

    application.lock() 
// your logic
    application.unlock() 

end sub 


You could use the global.asax file and add some custom code to the Session_OnStart event, you can get the user information and update it in a database which can feed your admin page.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜