问题
I have single R version 2.2.1. I implement custom Id Provider
public class ChatUserIdProvider : IUserIdProvider
{
    public string GetUserId(IRequest request)
    {
        if (request.User.Identity.IsAuthenticated)
        {
            Guid.Parse(request.User.Identity.GetUserId().ToString());
            var userId = request.User.Identity.GetUserId().ToString();
            return userId.ToString();
        }
        return "Un Known";
    }
}
I made a simple chat app and every think OK, but when I try to send a message to multi users the client event not firing here is hub function
public void SendToMany(string msg, List<string> userIds)
    {
        try
        {
           //db things here
            Clients.Users(userIds).sendMessage(msg);
        }
        catch (Exception ex)
        {
            Logs.Log(ex);
        }
    }
Startup
  GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new ChatUserIdProvider ());
        app.MapSignalR();
Js
$(function () {
   var chat = $.connection.chatHub;
    chat.client.sendMessage= function (msg) {
        $('.msgs').append('<div>'+ group.Name + '</div>');
        $('#' + group.Id).click();
    }
   $.connection.hub.start();
})
function BrodCast() {
    try {
        var chatids = new Array();
        $('.ckusergr').each(function () {
            if ($(this).is(':checked')) {
                chatids.push($(this).attr('iid'));
            }
        })
        chat.server.sendToMany($('.txtmsg').val(), chatids);
    } catch (e) {
        console.log(e)
    }
}
the problem with this line
public void SendToMany(string msg, List<string> userIds)
    {
        try
        {
           //db things here
            Clients.Users(userIds).sendMessage(msg); // Her is the Problem
        }
        catch (Exception ex)
        {
            Logs.Log(ex);
        }
    }
if I change to become like this every thing work great.
public void SendToMany(string msg, List<string> userIds)
    {
        try
        {
            //db things here
            foreach (string item in userIds)
            {
                Clients.User(item).sendMessage(msg);
            }
        }
        catch (Exception ex)
        {
            Logs.Log(ex);
        }
    }
    回答1:
I had similar problem today and I find out when I send as parameter List<string> which contains all usernames into Clients.Users(list of usernames) somehow it will work also.
I found this by accident, maybe someone with better experiences may clarify why this is working since this should only accept IList<string> userIds
回答2:
- First, you need to start your 
hubbefore declaring 'send' function. - Second, you should put your 
Broadcast functioninside the main function which is declaring variable chat. 
something like this should work :
$(function () {
   var chat = $.connection.chatHub;
    chat.client.sendMessage= function (msg) {
        $('.msgs').append('<div>'+ group.Name + '</div>');
        $('#' + group.Id).click();
    }
   $.connection.hub.start().done(function () {
        var chatids = new Array();
        $('.ckusergr').each(function () {
            if ($(this).is(':checked')) {
                chatids.push($(this).attr('iid'));
            }
        })
        chat.server.sendToMany($('.txtmsg').val(), chatids);
    });
})
    来源:https://stackoverflow.com/questions/42109363/signalr-clients-usersuserids-sendmsg-not-firing