Jon Davis
Jon Davis

Reputation: 6763

ASP.NET: Is it possible to iterate through all Session objects?

In ASP.NET 3.5, is it possible to iterate through all of the session objects (not the objects within the current session, but all sessions across all users) so that their collection contents can be manipulated (i.e. one collection item removed from all active sessions)?

And if so, does this work with ASP.NET State Service (accessing all sessions created by all web servers that are sharing the same state service, all from one web server)?

Upvotes: 2

Views: 2382

Answers (2)

Jon Davis
Jon Davis

Reputation: 6763

I think the only answer I've come up with is: If you're working with a single box, you can put the sessions into a collection that is stored in the Application collection, and remove each session when each session ends. But for making global session updates to a shared state server, credit goes to tvanfosson's comment under one of the other answers: SQL Server is the only reasonably viable option, outside of using a third party or alternate state server that enables this feature via network sockets.

Upvotes: 1

tvanfosson
tvanfosson

Reputation: 532435

This answer to a question I asked about removing a session from another session may be helpful to you. I haven't tried it and you'd need to extend it, but it appears possible to access the container for all sessions using reflection.

Upvotes: 1

Related Questions