共用方式為


HttpConnectionContextExtensions.GetHttpContext(ConnectionContext) 方法

定義

HttpContext如果有連接,則取得與連接相關聯的 。

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

參數

connection
ConnectionContext

ConnectionContext 表示連接。

傳回

HttpContext與連接相關聯的 ,如果連接不是以 HTTP 為基礎,則 null 為 。

備註

SignalR 連線可以在 WebSocket 或長輪詢或其他非 HTTP 傳輸等 HTTP 傳輸上執行。 因此,此方法有時會根據應用程式的組態傳回 null

適用於