HttpContext Class

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

Namespace
Microsoft.AspNetCore.Http
Assemblies
  • Microsoft.AspNetCore.Http.Abstractions

Syntax

public abstract class HttpContext
class Microsoft.AspNetCore.Http.HttpContext

Methods

Abort()

Aborts the connection underlying this request.

public abstract void Abort()

Properties

Microsoft.AspNetCore.Http.HttpContext.Authentication

Gets an object that facilitates authentication for this request.

Return type:Microsoft.AspNetCore.Http.Authentication.AuthenticationManager
public abstract AuthenticationManager Authentication { get; }
Microsoft.AspNetCore.Http.HttpContext.Connection

Gets information about the underlying connection for this request.

Return type:Microsoft.AspNetCore.Http.ConnectionInfo
public abstract ConnectionInfo Connection { get; }
Microsoft.AspNetCore.Http.HttpContext.Features

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

Return type:Microsoft.AspNetCore.Http.Features.IFeatureCollection
public abstract IFeatureCollection Features { get; }
Microsoft.AspNetCore.Http.HttpContext.Items

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

Return type:System.Collections.Generic.IDictionary<System.Object>
public abstract IDictionary<object, object> Items { get; set; }
Microsoft.AspNetCore.Http.HttpContext.Request

Gets the Microsoft.AspNetCore.Http.HttpRequest object for this request.

Return type:Microsoft.AspNetCore.Http.HttpRequest
public abstract HttpRequest Request { get; }
Microsoft.AspNetCore.Http.HttpContext.RequestAborted

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

Return type:System.Threading.CancellationToken
public abstract CancellationToken RequestAborted { get; set; }
Microsoft.AspNetCore.Http.HttpContext.RequestServices

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

Return type:System.IServiceProvider
public abstract IServiceProvider RequestServices { get; set; }
Microsoft.AspNetCore.Http.HttpContext.Response

Gets the Microsoft.AspNetCore.Http.HttpResponse object for this request.

Return type:Microsoft.AspNetCore.Http.HttpResponse
public abstract HttpResponse Response { get; }
Microsoft.AspNetCore.Http.HttpContext.Session

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

Return type:Microsoft.AspNetCore.Http.ISession
public abstract ISession Session { get; set; }
Microsoft.AspNetCore.Http.HttpContext.TraceIdentifier

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

Return type:System.String
public abstract string TraceIdentifier { get; set; }
Microsoft.AspNetCore.Http.HttpContext.User

Gets or sets the the user for this request.

Return type:System.Security.Claims.ClaimsPrincipal
public abstract ClaimsPrincipal User { get; set; }
Microsoft.AspNetCore.Http.HttpContext.WebSockets

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

Return type:Microsoft.AspNetCore.Http.WebSocketManager
public abstract WebSocketManager WebSockets { get; }