Reputation: 23935
Is there any way to access the collection of current sessions in ASP.NET globally from the application?
Thanks.
Upvotes: 6
Views: 229
Reputation: 5750
I don't think so, but you can manage your own list in the global.a s a x
void Session_Start(object sender, EventArgs e)
{
//add current session to your own application shared collection
}
void Session_End(object sender, EventArgs e)
{
//remove session
}
Upvotes: 0
Reputation: 7824
If you store session state in SQL Server, you would have access to all the sessions via SQL Server.
There is also Application State - which can be used to access information across the application, but this has many caveats.
Upvotes: 1
Reputation: 3335
No, sessions are sandboxed, they are totally separate from each other. What you could do is managing a psueudo-session collection in the shared Application object and implement the Session_Start method to populate that collection.
Upvotes: 4