DorR
DorR

Reputation: 645

ASP.NET Get all user sessions for web application

I need to find a way to retrieve all of the user sessions from within a web application. I have tried this solution: Get a list of all active sessions in ASP.NET

And it worked fine for .net 4.5 and above but not for 4.0 and below.

I don't want to manage my sessions by creating a static list of sessions that will be populated from Global.asax (session_start and session_end). I just need to find a way to investigate the current web application and retrieve all of the users active sessions (for .net versions 2.0 and above)

Is it possible?

Upvotes: 2

Views: 7248

Answers (2)

qbik
qbik

Reputation: 5908

You could use a SQLServer SessionState Store Provider and then get the stored sessions from the database. Or implement your own custom Provider. Both options seem like a little overkill comparing to a simple session_start/session_end you mentioned.

Upvotes: 2

Imamul Karim Tonmoy
Imamul Karim Tonmoy

Reputation: 584

did you mean that , you have a, b , c three uses in different pc using same application through iis, and you need to access all user session from on of pc.

then you may need to use save the session in state server. rather then apllication sate. then you may try follwoing code. it may be work

for (int i = 0; i < Session.Count; i++)
        {
             Session[i].ToString();
        }

i am not sure. hope this will help you.

Upvotes: 0

Related Questions