如何从SignalR中的IHubContext获取当前用户?

问题描述 投票:1回答:1

假设在某些类库中我可以访问特定的HubContext

IHubContext ctx = connectionManager.GetHubContext<MyAwesomeHub>();

如何访问当前经过身份验证的.User属性?

signalr signalr-hub
1个回答
2
投票

你不能。 GetHubContext方法通常用于将消息从后台线程发送到客户端(或许多/所有客户端),因此根据定义,不会有SignalR用户支持它。

© www.soinside.com 2019 - 2024. All rights reserved.