There is a way to manage how many sessions an asp.net running aplication have? I want to exhibit it in a page, maybe with some other important information, if available. And, how can I do it?
In global.asax
, do the following:
Handle the Application.Start
event adding the following:
Application["LiveSessionsCount"] = 0;
Handle the Session.Start
event adding the following:
Application["LiveSessionsCount"] = ((int) Application["LiveSessionsCount"]) + 1;
Handle the Session.End
event adding the following:
Application["LiveSessionsCount"] = ((int) Application["LiveSessionsCount"]) - 1;
To retrieve sessions count inside your page write the following:
int LiveSessionsCount = (int) Application["LiveSessionsCount"];
Perhaps in your global.asax file Session_Start and Session_End events, you can store session information to a userinfo array within your application state object. Then you can manage this array from App State throughout your application.
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