I need to pass User.Identity.Name
to Windows Form client.
Method
public override Task OnConnected() {
string userName = Context.User.Identity.Name;
string connectionId = Context.ConnectionId;
var user = Users.GetOrAdd(userName, _ => new User {
Name = userName,
ConnectionIds = new HashSet<string>()
});
lock (user.ConnectionIds) {
user.ConnectionIds.Add(connectionId);
if (user.ConnectionIds.Count == 1) {
Clients.Others.userConnected(userName);
}
}
return base.OnConnected();
}
But Context.User.Identity.Name
is null? Why? How to solve it?