I am using SignalR in my ASP.NET web application. Here I am calling client from outside to hub class using IHubContext
. I need to get the current user's connection ID in order to send messages to the current user only. How can I get the connection ID on the client side?
For a . NET Client it is on the Connection object, inherited by HubConnection . Show activity on this post. There's another way also, you can get connection id into your controller from hub by invoking a method of hub and you can return the required ID from there.
The Context objectThe Hub class includes a Context property that contains the following properties with information about the connection: Property. Description. ConnectionId. Gets the unique ID for the connection, assigned by SignalR.
Yep. You can use $.connection.hub.id
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With