Why Context.User.Identity.Name is null in Windows Form Hub Context?

人盡茶涼 提交于 2019-12-06 05:06:55

It looks like you are trying to get the username when connecting to the hub. I solved a similar issue by passing the username from my client. It also sounds like you are making use of the SignalR .NET client. Give this a try

Client

Connection = new HubConnection("http://.../", new Dictionary<string, string>
{
    { "UserName", WindowsIdentity.GetCurrent().Name }
});

Hub

public override Task OnConnected()
{
    string userName = Context.QueryString["UserName"]
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!