Determining an 'active' user count of an ASP.NET site

后端 未结 9 2099
南旧
南旧 2021-01-01 01:36

On an ASP.NET site, what are some techniques that could be used to track how many users are logged in to the site at any given point in time?

So for example, I could

9条回答
  •  感动是毒
    2021-01-01 02:13

    If using SQL Server for Session storage (i.e. mode is "SQLServer" in web.config), you can't use a solution that relies on Session_End in global.asax, as the method will never be called.

    However, assuming that SQL Agent is running the DeleteExpiredSessions job correctly (which it should be by default when SQL State was installed), you can just run the following SQL against the Session Db:

    SELECT COUNT(SessionId) FROM ASPStateTempSessions
    

提交回复
热议问题