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;