How to get the AspNet Core SignalR Transport Proto

2019-07-29 17:17发布

问题:

In the old SignalR, you could do this to get the transport in the Hub on the Server:

Context.QueryString["transport"];

But in the new SignalR, written for AspNet Core, I couldn't find where the Transport Protocol can be found within the Hub on the Server. Can it be found? If so, where?

回答1:

As of ASP.NET Core SignalR 1.0.0-rc1-final (commit), you can get the TransportType from:

// using Microsoft.AspNetCore.Http.Connections.Features;

var transportType = Context.Features.Get<IHttpTransportFeature>().TransportType;