SignalR cannot read property client of undefined

前端 未结 10 2271
醉话见心
醉话见心 2020-12-13 08:42

I\'m trying to add SignalR to my project (ASPNET MVC 4). But I can\'t make it work.

In the below image you can see the error I\'m receiving.

10条回答
  •  天命终不由人
    2020-12-13 08:58

    For those who tried to add the generated proxy file path in the bundle.

    Do not include the "~/signalr/hubs" in your BundleConfig.cs.

    You can have the JQuery.SignalR in the bundle:

    bundles.Add(new ScriptBundle("~/bundles/signalr").Include(
                      "~/Scripts/jquery.signalR-{version}.js"));
    

    But you will need to add "/signalr/hubs" it in your view:

    @section Scripts {
        @Scripts.Render("~/bundles/signalr")
        @Scripts.Render("/signalr/hubs")
    }
    

    I hope this helps.

提交回复
热议问题