Server side:
public override Task OnConnected()
{
var connectionId = Context.ConnectionId;
var user = Context.User.Identity.Name; // Context.User is NULL
return base.OnConnected();
}
Client side (in Console project):
IHubProxy _hub;
string url = @"http://localhost:8080/";
var connection = new HubConnection(url);
_hub = connection.CreateHubProxy("TestHub");
connection.Start().Wait();
When the client connect to the server, I want to know the map between userName and connectionId, But Context.User
is NULL. How do I set this value in the client side?
Client
Server
try this
Client (C#)
Server
Pass your username using query string.
Client
First set query string
Server
try this with queryString in asp.netcore 2.1:
Client (javascript) set query string after url like follow:
Server