Search code examples
asp.net-coresignalrasp.net-core-2.1

How can I connect to a SignalR hub using ASP.NET Core 2.1


I am trying to connect to SignalR hubs from an ASP.NET Core 2.1 project. Looking at the documentation here: https://learn.microsoft.com/en-us/aspnet/core/signalr/dotnet-client?view=aspnetcore-2.2, it says a package reference to Microsoft.AspNetCore.SignalR.Client is required.

Looking at the NuGet site (https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/) for this library, no versions for .NET Core 2.X are available.

How come there are no versions for 2.1 available? What library can I use for connecting to SignalR hubs using .NET Core 2.1, if not Microsoft.AspNetCore.SignalR.Client?


Solution

  • The SignalR version numbers are a bit confusing because SignalR was actually not available with ASP.NET Core 1.x but came later with 2.x. And it shipped on a separate lifecycle which you can also see by the versions of the Microsoft.AspNetCore.SignalR package. So basically, the numbers are just very out of sync with ASP.NET Core versions.

    They are fixing that in ASP.NET Core 3, where SignalR and its clients will be regular parts of ASP.NET Core, shipping normally with the framework and sharing version numbers.

    For 2.x this basically means that you just pick the latest SignalR 1.x. To verify the best version, you should also look at the dependencies of Microsoft.AspNetCore.SignalR.Core which is the base dependency for both the client as well as the server package. You will see that it also depends on Microsoft.AspNetCore.Authorization. So that should be your indicator which version to use for which version of ASP.NET Core.

    To summarize: