Delen via


HttpContextServerVariableExtensions.GetServerVariable Method

Definition

Gets the value of a server variable for the current request.

public:
[System::Runtime::CompilerServices::Extension]
 static System::String ^ GetServerVariable(Microsoft::AspNetCore::Http::HttpContext ^ context, System::String ^ variableName);
public static string GetServerVariable (this Microsoft.AspNetCore.Http.HttpContext context, string variableName);
public static string? GetServerVariable (this Microsoft.AspNetCore.Http.HttpContext context, string variableName);
static member GetServerVariable : Microsoft.AspNetCore.Http.HttpContext * string -> string
<Extension()>
Public Function GetServerVariable (context As HttpContext, variableName As String) As String

Parameters

context
HttpContext

The http context for the request.

variableName
String

The name of the variable.

Returns

null if the server does not support the IServerVariablesFeature feature. May return null or empty if the variable does not exist or is not set.

Applies to