JQuery 3 and SignalR 2.2.0

后端 未结 3 1839
离开以前
离开以前 2020-12-15 19:04

I use SignalR 2.2.0 in a MVC5 project. SignalR depends of JQuery in client-side.

JQuery recently released new version, I updated it from Nuget, specifically from ver

3条回答
  •  粉色の甜心
    2020-12-15 19:20

    If you're still getting errors like this after updating to 2.2.1 and jQuery 3.x then read on...

    TypeError: Cannot read property 'client' of undefined
    

    Like I am you are probably using the dynamically generated proxy, and you checked your /signalr/hubs file and found you don't have any proxies defined.

     var proxies = {};
    

    Wait you may ask I didn't change anything - where did they go?

    Well, like me you probably were in such a hurry to upgrade signalR to 2.2.1 that you forgot to do it in all your projects and now you are using both 2.2.1 and 2.2.0 in different assemblies. (I am defining my hubs in a different assembly than my main app).

    All I needed to do was make sure I had the latest nuget package version in every project and it all worked. Should work fine after rebuilding. If not, this may also help.

    Also do yourself a favor and read the jQuery 3 upgrade guide if you use much jQuery elsewhere.

提交回复
热议问题