0

为什么我会收到此错误:

myhub.cs:

  public class ChatHub : Hub
{
 private static DataTable ConnectedClientDt = null;

  public void ConnectClient(string ClientName)
  {
    if (ConnectedClientDt == null)
    {
        ConnectedClientDt = new DataTable();
        ConnectedClientDt.Columns.Add("ClienID");
        ConnectedClientDt.Columns.Add("ClientName");
    }
    ConnectedClientDt.Rows.Add(Context.ConnectionId,ClientName);

}

客户端 :

 $(document).ready(function () {
        var chat = $.connection.chatHub;
        var clientName = '<%=Session["ClientName"] %>';

        $.connection.hub.start().done(function () {
            chat.server.ConnectClient(clientName);

        });

请有任何帮助

4

1 回答 1

0

将名称更改为小写。ConnectClient 应该是 connectClient。一开始可能会令人困惑,因为我们将名称设为 javascript 友好名称(驼峰式)

于 2013-03-04T11:08:16.310 回答