Support Thread

Active User Count Does Not Show Up Or Always 0

Active User Count Does Not Show Up Or Always 0 — APG vNext Guide

Active User Count Does Not Show Up Or Always 0 — an archived discussion from the APG vNext support community.

About This Topic

This thread covers active user count does not show up or always 0 in the context of APG vNext, the ASP.NET forum and community platform. The community includes APG developers and experienced administrators who can help with similar questions.

APG vNext Support

APG vNext Active User Count Shows 0 or Doesn't Display — Root Cause and Fix

The "members online" or active user count widget in APG vNext pulls from a session tracking table that is updated every time a member or guest loads a page. When this count shows 0 or fails to display entirely, it almost always points to one of three issues: session state misconfiguration, the session tracking table not being updated, or a caching layer returning stale data. This guide covers each case with specific fixes.

How APG vNext Tracks Active Users

On each page request, APG vNext writes or updates a row in the apg_ActiveUsers table with the user's ID (or a guest token), the current timestamp, and the page they are viewing. The "members online" count is a simple COUNT(*) query on this table filtered to the last N minutes (default: 15). If the writes are not happening, the count stays at 0.

Diagnosis Step 1 — Check the Table Directly

-- Is the table being written to?
SELECT COUNT(*) AS ActiveCount,
       MAX(LastActivity) AS MostRecent
FROM   apg_ActiveUsers
WHERE  LastActivity > DATEADD(MINUTE, -15, GETDATE());

-- If ActiveCount = 0 and MostRecent is NULL or old,
-- the writes are not happening.

Fix 1 — Session State Configuration

APG vNext's active user tracking requires that ASP.NET session state is functioning correctly. If session state is set to Off or the SQL Server session state database is not reachable, the tracking middleware skips the write silently.

<system.web>
  <!-- Ensure session state is enabled -->
  <sessionState mode="InProc"
                timeout="20"
                cookieless="false" />
</system.web>

For web farm deployments using SQL Server session state, confirm the ASPState database is accessible from all web servers and that the application pool identity has read/write permissions on it.

Fix 2 — Output Cache Bypassing the Active User Write

If output caching is enabled for the forum home page at a duration longer than the active user window (15 minutes), the page is served from cache without executing the active user tracking code. Exempt the active user tracking from cache:

<!-- Vary the cache by session so each user gets a fresh count -->
<outputCacheSettings>
  <outputCacheProfiles>
    <add name="ForumHome" duration="60"
         varyByParam="none"
         varyByCustom="user" />
  </outputCacheProfiles>
</outputCacheSettings>

Alternatively, disable output caching for the widget section only by rendering it via an AJAX call that bypasses the page cache.

Fix 3 — Missing Database Index Causing Timeout

On large installations, the active user cleanup job (which deletes rows older than 15 minutes) can lock the table if no index exists on LastActivity. This causes the widget query to time out and return 0. Add the index:

CREATE NONCLUSTERED INDEX IX_apg_ActiveUsers_LastActivity
ON apg_ActiveUsers (LastActivity DESC);

Fix 4 — Firewall Blocking Session State Writes (SQL Server Session State)

For web farm deployments using SQL Server session state, a network misconfiguration between the IIS server and the SQL Server session state instance can prevent session writes without producing an obvious error. The symptom is that active user counts work on the first server in the farm but not on others.

-- Verify ASPState database is accessible from all web servers:
-- Run on each web server:
sqlcmd -S sessionStateServer -d ASPState -Q "SELECT GETDATE()"

-- If connection fails, check:
-- 1. Firewall allows TCP 1433 between web servers and session state SQL Server
-- 2. Service account has db_owner on ASPState database
-- 3. Named Pipes vs. TCP/IP configuration on SQL Server

Fix 5 — Guest Tracking Disabled

By default, APG vNext tracks both logged-in members and anonymous guests in the active user count. If guest tracking is disabled, the count will appear much lower than actual traffic (because most community visitors are guests). Check Admin Panel → Settings → Display → Track Guest Sessions.

<!-- Enable guest tracking in web.config -->
<add key="APG.ActiveUsers.TrackGuests"     value="true" />
<add key="APG.ActiveUsers.GuestTimeout"    value="15" /> <!-- minutes -->
<add key="APG.ActiveUsers.ShowGuestCount"  value="true" />

Displaying Active User Count Accurately in the Homepage Widget

Once the underlying tracking is working, the widget display itself may still be stale due to output caching. The active user widget in APG vNext should render with a very short or zero cache duration — unlike thread listing pages, the value of this widget is real-time data:

<!-- Make the active user widget bypass the page output cache -->
<!-- In the APG vNext skin template, wrap the widget call: -->
<% Response.Cache.SetNoStore(); %>
<%= APGWidget.ActiveUsers(showGuests: true, minuteWindow: 15) %>

<!-- Or use an AJAX call to a dedicated endpoint: -->
fetch('/api/v1/stats/active-users')
  .then(r => r.json())
  .then(data => {
    document.getElementById('active-count').textContent = data.count;
  });

The AJAX approach completely bypasses page output caching and delivers a live count on every page refresh, at the cost of an additional HTTP request per page view.

Related Resources


Looking for more help? Browse the support forum or check the Knowledge Base.