HttpConnectionContextExtensions.GetHttpContext(ConnectionContext) Method

Definition

Gets the HttpContext associated with the connection, if there is one.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Http::HttpContext ^ GetHttpContext(Microsoft::AspNetCore::Connections::ConnectionContext ^ connection);
public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext (this Microsoft.AspNetCore.Connections.ConnectionContext connection);
public static Microsoft.AspNetCore.Http.HttpContext? GetHttpContext (this Microsoft.AspNetCore.Connections.ConnectionContext connection);
static member GetHttpContext : Microsoft.AspNetCore.Connections.ConnectionContext -> Microsoft.AspNetCore.Http.HttpContext
<Extension()>
Public Function GetHttpContext (connection As ConnectionContext) As HttpContext

Parameters

connection
ConnectionContext

The ConnectionContext representing the connection.

Returns

The HttpContext associated with the connection, or null if the connection is not HTTP-based.

Remarks

SignalR connections can run on top of HTTP transports like WebSockets or Long Polling, or other non-HTTP transports. As a result, this method can sometimes return null depending on the configuration of your application.

Applies to