Pages

Saturday, February 1, 2014

SignalR and MVC4

I had to use SignalR this week and it was quite funny experience :) And, fortunately, successful!

The main problem I`ve faced was about different versions of the SignalR and MVC. If you would try to install SignalR package with windowed NuGet interface you will find that it can install the latest version - 2.0.2. But the installation will fail, because it uses the latest version of OWIN.Security, which requires .Net 4.5...

So the solution is to use NuGet console! Use
install-package Microsoft.AspNet.SignalR -Version 1.1.3
and it will install everything! Then, as always create a new hub class, register it and add signalr.js and signalr/hubs scripts. (as in tutorial).

But for me it was little harder :) I`ve tried to add SignalR 2.0 and failed, but it have not rolled back correctly. The javascript files were left in Scripts folder... And when I`ve reinstalled the correct version they were not downgraded!

Because of that I was not able to connect to hub - my overridden OnConnect just was not called! I had to make parallel project and install everything in there in a right way to connect...

Hope this notes will help someone :)

No comments:

Post a Comment