Dela via


HttpContext Class

Definition

Encapsulates all HTTP-specific information about an individual HTTP request.

public ref class HttpContext abstract
public abstract class HttpContext
type HttpContext = class
Public MustInherit Class HttpContext
Inheritance
HttpContext
Derived

Constructors

HttpContext()

Properties

Authentication
Obsolete.

This is obsolete and will be removed in a future version. The recommended alternative is to use Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions. See https://go.microsoft.com/fwlink/?linkid=845470.

Connection

Gets information about the underlying connection for this request.

Features

Gets the collection of HTTP features provided by the server and middleware available on this request.

Items

Gets or sets a key/value collection that can be used to share data within the scope of this request.

Request

Gets the HttpRequest object for this request.

RequestAborted

Notifies when the connection underlying this request is aborted and thus request operations should be cancelled.

RequestServices

Gets or sets the IServiceProvider that provides access to the request's service container.

Response

Gets the HttpResponse object for this request.

Session

Gets or sets the object used to manage user session data for this request.

TraceIdentifier

Gets or sets a unique identifier to represent this request in trace logs.

User

Gets or sets the user for this request.

WebSockets

Gets an object that manages the establishment of WebSocket connections for this request.

Methods

Abort()

Aborts the connection underlying this request.

Extension Methods

AuthenticateAsync(HttpContext, String)

Authenticate the current request using the specified scheme.

AuthenticateAsync(HttpContext)

Authenticate the current request using the default authentication scheme. The default authentication scheme can be configured using DefaultAuthenticateScheme.

ChallengeAsync(HttpContext, AuthenticationProperties)

Challenge the current request using the default challenge scheme. An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication. The default challenge scheme can be configured using DefaultChallengeScheme.

ChallengeAsync(HttpContext, String, AuthenticationProperties)

Challenge the current request using the specified scheme. An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.

ChallengeAsync(HttpContext, String)

Challenge the current request using the specified scheme. An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication.

ChallengeAsync(HttpContext)

Challenge the current request using the default challenge scheme. An authentication challenge can be issued when an unauthenticated user requests an endpoint that requires authentication. The default challenge scheme can be configured using DefaultChallengeScheme.

ForbidAsync(HttpContext, AuthenticationProperties)

Forbid the current request using the default forbid scheme. Forbid is used when an authenticated user attempts to access a resource they are not permitted to access. The default forbid scheme can be configured using DefaultForbidScheme.

ForbidAsync(HttpContext, String, AuthenticationProperties)

Forbid the current request using the specified scheme. Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.

ForbidAsync(HttpContext, String)

Forbid the current request using the specified scheme. Forbid is used when an authenticated user attempts to access a resource they are not permitted to access.

ForbidAsync(HttpContext)

Forbid the current request using the default forbid scheme. Forbid is used when an authenticated user attempts to access a resource they are not permitted to access. The default forbid scheme can be configured using DefaultForbidScheme.

GetTokenAsync(HttpContext, String, String)

Authenticates the request using the specified scheme and returns the value for the token.

GetTokenAsync(HttpContext, String)

Authenticates the request using the default authentication scheme and returns the value for the token. The default authentication scheme can be configured using DefaultAuthenticateScheme.

SignInAsync(HttpContext, ClaimsPrincipal, AuthenticationProperties)

Sign in a principal for the default authentication scheme. The default scheme for signing in can be configured using DefaultSignInScheme.

SignInAsync(HttpContext, ClaimsPrincipal)

Sign in a principal for the default authentication scheme. The default scheme for signing in can be configured using DefaultSignInScheme.

SignInAsync(HttpContext, String, ClaimsPrincipal, AuthenticationProperties)

Sign in a principal for the specified scheme.

SignInAsync(HttpContext, String, ClaimsPrincipal)

Sign in a principal for the specified scheme.

SignOutAsync(HttpContext, AuthenticationProperties)

Sign out a principal for the default authentication scheme. The default scheme for signing out can be configured using DefaultSignOutScheme.

SignOutAsync(HttpContext, String, AuthenticationProperties)

Sign out a principal for the specified scheme.

SignOutAsync(HttpContext, String)

Sign out a principal for the specified scheme.

SignOutAsync(HttpContext)

Sign out a principal for the default authentication scheme. The default scheme for signing out can be configured using DefaultSignOutScheme.

AcceptsInteractiveRouting(HttpContext)

Determines whether the current endpoint is a Razor component that can be reached through interactive routing. This is true for all page components except if they declare the attribute ExcludeFromInteractiveRoutingAttribute.

GetEndpoint(HttpContext)

Extension method for getting the Endpoint for the current request.

SetEndpoint(HttpContext, Endpoint)

Extension method for setting the Endpoint for the current request.

GetServerVariable(HttpContext, String)

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

GetHttpRequestMessage(HttpContext)
GetRouteData(HttpContext)

Gets the RouteData associated with the provided httpContext.

GetRouteValue(HttpContext, String)

Gets a route value from Values associated with the provided httpContext.

GetIISServerVariable(HttpContext, String)
Obsolete.

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

Applies to