Is there any way to access the collection of current sessions in ASP.NET globally from the application?
Thanks.
InProc mode, which stores session state in memory on the Web server. This is the default.
By default, ASP.NET will store session information in memory inside of the worker process (InProc), typically w3wp.exe . There are other modes for storing session, such as Out of Proc and a SQL Server.
The Session object stores information about, or change settings for a user session. Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences.
Session variables are stored in a SessionStateItemCollection object that is exposed through the HttpContext. Session property. In an ASP.NET page, the current session variables are exposed through the Session property of the Page object.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With