SignalR: UseSignalR and UseConnections methods removed

In ASP.NET Core 3.0, SignalR adopted endpoint routing. As part of that change, the UseSignalR, UseConnections, and some related methods were marked as obsolete. In ASP.NET Core 5.0, those obsolete methods were removed. For the full list of methods, see Affected APIs.

For discussion on this issue, see dotnet/aspnetcore#20082.

Version introduced

5.0 Preview 3

Old behavior

SignalR hubs and connection handlers could be registered in the middleware pipeline using the UseSignalR or UseConnections methods.

New behavior

SignalR hubs and connection handlers should be registered within UseEndpoints using the MapHub and MapConnectionHandler extension methods on IEndpointRouteBuilder.

Reason for change

The old methods had custom routing logic that didn't interact with other routing components in ASP.NET Core. In ASP.NET Core 3.0, a new general-purpose routing system, called endpoint routing, was introduced. Endpoint routing enabled SignalR to interact with other routing components. Switching to this model allows users to realize the full benefits of endpoint routing. Consequently, the old methods have been removed.

Remove code that calls UseSignalR or UseConnections from your project's Startup.Configure method. Replace it with calls to MapHub or MapConnectionHandler, respectively, within the body of a call to UseEndpoints. For example:

Old code:

app.UseSignalR(routes =>
{
    routes.MapHub<SomeHub>("/path");
});

New code:

app.UseEndpoints(endpoints =>
{
    endpoints.MapHub<SomeHub>("/path");
});

In general, your previous MapHub and MapConnectionHandler calls can be transferred directly from the body of UseSignalR and UseConnections to UseEndpoints with little-to-no change needed.

Affected APIs