Context.User.Identity.Name
is always empty, currently I am using WebForms:
HttpCookie cookie = new HttpCookie("jamal");
cookie.Value = "bilal";
HttpContext.Current.Response.Cookies.Add(cookie);
Here I want username:
public override Task OnConnected()
{
AddUser(Context.User.Identity.Name, this.Context.ConnectionId);
}
private static void AddUser(String username, String connectionId)
{
ISet<String> connections;
if (users.TryGetValue(username, out connections) == false)
{
connections = users[username] = new HashSet<String>();
}
connections.Add(connectionId);
}