In a`HubConnection` how to get the login info? how to use a username and password to get the user info?
In a`HubConnection` how to get the login info? how to use a username and password to get the user info?
Hi @6666666,
HubConnection should be created using HubConnectionBuilder. Before hub methods can be invoked the connection must be started using StartAsync(). Clean up a connection using StopAsync() or DisposeAsync().
I suggest that you can get user information from the Disconnect method in the form of Context.ConnectionId.
You can refer to the following article:
https://docs.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-5.0
https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/mapping-users-to-connections
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Lan Huang
2 people are following this question.