No access to the Session information through SignalR Hub. Is my design is wrong?

You shouldn’t use Session with SignalR (see SignalR doesn’t use Session on server). You identify logical connections by their connection id which you can map to user names.

The underlying problem is that access to SessionState is serialized in ASP.NET to ensure state consistency, so each request to the hub would block other requests. In the past, limited read-only access (I assume (but can’t confirm since the gist is gone) by setting EnableSessionstate to read-only, which prevents the locking problem I described) was possible, but support for this was dropped. Also see various other places where the SignalR team made similar statements. Lastly: there’s a statement in the official documentation about HTTPContext.Current.Session.

Leave a Comment