The most common way would be to maintain a static List<CustomType> in your hub, where CustomType has the UserId and ConnectionId properties
Here is an example you can follow: http://www.tugberkugurlu.com/archive/mapping-asp-net-signalr-connections-to-real-application-users
I write my connection identifiers to the sql database in the SignalR.OnConnected event and delete them in the SignalR.OnDisconnected event, you will get some records of lost connections in your table that are not very important, just make sure you have the created_date column and ignore any connections that take so many hours or days depending on your needs. There is also no session in SignalR, donβt even try, this is a known issue. To get your current user, modern out-of-the-box Microsoft MVC membership providers work fine. But you can also easily use cookies to get the current username / id.
source share