Calling dot net client method from outside hub RRS feed

  • Question

  • User-1279551119 posted
    var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<TimeEntryHubs.TimeEntrySettingsHub>();
    if (TimeEntryHubs.TimeEntrySettingsHub.Users.Any(f => f.Value == userId))
        var connectionID = TimeEntryHubs.TimeEntrySettingsHub.Users.Where(f => f.Value == userId).Single().Key;

    I have a hub class in asp.net web application

    Above code is on server side in aspx code behind ,

    following code is on client side , hub is connecting properly connected disconnected get called properly only hub method call from outside hub class is not working

    HubProxy.On("ApplyChangeSettings", (userid) => ApplyChangedSettings().Wait());
    public async Task ApplyChangedSettings()
        if (ConnectionTimeEntryHub.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
    	  var d = await HubProxy.Invoke<TimeEntryV2.Models.Models.UpdatingSettings>("GetSettings",User.UserIdentity);
    	   TimeEntrySettings = d;

    Tuesday, June 9, 2015 1:03 AM


All replies

  • User1711366110 posted

    HubProxy.On("ApplyChangeSettings", (userid) => ApplyChangedSettings().Wait());

       As per this case, you can replace the following code :

    HubProxy.On("ApplyChangedSettings", (userid) => ApplyChangedSettings().Wait());

    Please make sure that the same function called from serverside.
    Moreover I suggest you to refer the following similar link which may guide you to resolve this case :

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 9, 2015 10:26 PM
  • User1118272100 posted


    You need to call Invoke on the method on the hub class and then create a call back for the dynamic method that you hub invokes. 

    When you call invoke like: 

    var d = await HubProxy.Invoke<TimeEntryV2.Models.Models.UpdatingSettings>("GetSettings",User.UserIdentity); 

    ...you need to have a GetSettings method on the hub. If you have this method, then debug the server an see if it gets called.

    I have written a blog post about how to call hub methods from .NET clients, the example is in WPF, that explains it in more details. You can find it right here: 


    Thursday, June 11, 2015 6:34 AM