79678907

Date: 2025-06-25 10:56:49
Score: 1.5
Natty:
Report link

SignalR Hubs don't share the same context as ASP.NET MVC controllers, so HttpContext.Session is not available inside Hub methods or event handlers wired via Hub.

A better pattern is to use a concurrent dictionary or an in-memory cache to store connection info when a user connects.

You can listen to OnConnectedAsync() or create a shared static store where you map connection IDs to user-specific data.

This scenario is discussed with implementation steps in this SignalR integration example: https://saigontechnology.com/blog/real-time-aspnet-with-signalr/

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Saigon Technology