From 357ef84001185a4b80ffab499dd0481b622fecc4 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Thu, 14 May 2026 17:16:54 -0400 Subject: [PATCH] Fix online users page always showing /InAppNotifications/Recent as current page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The notification bell polls /InAppNotifications/Recent (a JSON endpoint) every time it loads. Because the middleware throttles updates to once per 60s, the update fired on whichever request first arrived after the throttle expired — usually the bell poll rather than a real page navigation. Fix: skip any response whose Content-Type is application/json so only full page navigations update the current-page field. Co-Authored-By: Claude Sonnet 4.6 --- src/PowderCoating.Web/Middleware/OnlineUserMiddleware.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PowderCoating.Web/Middleware/OnlineUserMiddleware.cs b/src/PowderCoating.Web/Middleware/OnlineUserMiddleware.cs index cf7d15b..f915e8f 100644 --- a/src/PowderCoating.Web/Middleware/OnlineUserMiddleware.cs +++ b/src/PowderCoating.Web/Middleware/OnlineUserMiddleware.cs @@ -50,6 +50,12 @@ public class OnlineUserMiddleware { await _next(context); + // Skip AJAX/JSON responses — they are not page navigations and would + // cause the "current page" to show the polling endpoint (e.g. /InAppNotifications/Recent) + // rather than the actual page the user is on. + if (context.Response.ContentType?.Contains("application/json", StringComparison.OrdinalIgnoreCase) == true) + return; + // Only track authenticated, non-API, non-asset requests if (!context.User.Identity?.IsAuthenticated ?? true) return; var path = context.Request.Path.Value ?? string.Empty;