SignalR cannot read property client of undefined

前端 未结 10 2269
醉话见心
醉话见心 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 09:11

    Make sure you add

    app.MapSignalR();
    

    inside startup.cs and Configuration method, like this:

     public partial class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                app.MapSignalR();
            }
        }
    

    For Asp.net Core

    Add

    services.AddSignalR();
    

    in ConfigureServices methode in your startup.cs

    And add

    app.UseSignalR(routes =>
                {
                    routes.MapHub("/chatHub");
                });
    

    in Configure methode in your startup.cs

提交回复
热议问题