Search code examples
signalrasp.net-core-signalr

How to get the AspNet Core SignalR Transport Protocol in the Hub?


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?


Solution

  • 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;