Fix online users page always showing /InAppNotifications/Recent as current page
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user