try this with queryString in asp.netcore 2.1 :
The client (javascript) query string after the URL is as follows:
var connection = new signalR.HubConnectionBuilder().withUrl("http://localhost:10499/chathub?username=xxxx").build();
connection.start().then(function ()
{
}).catch(function (err)
{
console.error(err.toString());
});
.
.
.
server
public override Task OnConnectedAsync()
{
var username = Context.GetHttpContext().Request.Query["username"];
return base.OnConnectedAsync();
}