I would like to understand why Context.User.Identity.Name
is null
and why Context.User.Identity.IsAuthenticated
is false
inside a signalr Hub in the onConnectedAsync
method? Msdn says:
"SignalR can be used with ASP.NET Core authentication to associate a user with each connection...
In a browser-based app, cookie authentication allows existing user credentials to automatically flow to SignalR connections. When using the browser client, no extra configuration is needed. If the user is logged in to an app, the SignalR connection automatically inherits this authentication."
Project code available here :
https://github.com/nl20121974/CC
Précision : in this case, user was previously authenticated with the standard authentication form against membership individual accounts (database username + password) from the blazor app. I started with the Microsoft blazor chat sample. This one :
https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-tutorial-build-blazor-server-chat-app
The user logs in first from the authentication form with credentials (username + password) from database (.net membership) and goes to the chat page where the user name is automatically sent to chat hub when the "Chat" button is clicked.
I would like to fill a connected users list from signalr hub directly
I searched on Msdn blazor and signalr documentation and Googled a lot.