Dela via


DefaultHttpContext Class

Definition

Represents an implementation of the HTTP Context class.

public ref class DefaultHttpContext : Microsoft::AspNetCore::Http::HttpContext
public ref class DefaultHttpContext sealed : Microsoft::AspNetCore::Http::HttpContext
public class DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext
public sealed class DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext
type DefaultHttpContext = class
    inherit HttpContext
Public Class DefaultHttpContext
Inherits HttpContext
Public NotInheritable Class DefaultHttpContext
Inherits HttpContext
Inheritance
DefaultHttpContext

Constructors

DefaultHttpContext()

Initializes a new instance of the DefaultHttpContext class.

DefaultHttpContext(IFeatureCollection)

Initializes a new instance of the DefaultHttpContext class with provided features.

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.

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.

(Inherited from HttpContext)
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.

FormOptions

Gets or set the FormOptions for this instance.

HttpContext

This API is used by ASP.NET Core's infrastructure and should not be used by application code.

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.

ServiceScopeFactory

Gets or sets the IServiceScopeFactory for this instance.

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.

Initialize(IFeatureCollection)

Reinitialize the current instant of the class with features passed in.

InitializeAuthenticationManager()
InitializeConnectionInfo()
InitializeHttpRequest()
InitializeHttpResponse()
InitializeWebSocketManager()
Uninitialize()

Uninitialize all the features in the DefaultHttpContext.

UninitializeAuthenticationManager(AuthenticationManager)
UninitializeConnectionInfo(ConnectionInfo)
UninitializeHttpRequest(HttpRequest)
UninitializeHttpResponse(HttpResponse)
UninitializeWebSocketManager(WebSocketManager)

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