Uredi

Deli z drugimi prek


HttpContextBase Class

Definition

Serves as the base class for classes that contain HTTP-specific information about an individual HTTP request.

public ref class HttpContextBase abstract : IServiceProvider
public abstract class HttpContextBase : IServiceProvider
type HttpContextBase = class
    interface IServiceProvider
Public MustInherit Class HttpContextBase
Implements IServiceProvider
Inheritance
HttpContextBase
Derived
Implements

Remarks

The HttpContextBase class is an abstract class that contains the same members as the HttpContext class. The HttpContextBase class enables you to create derived classes that are like the HttpContext class, but that you can customize and that work outside the ASP.NET pipeline. When you perform unit testing, you typically use a derived class to implement members with customized behavior that fulfills the scenario you are testing.

The HttpContextWrapper class derives from the HttpContextBase class. The HttpContextWrapper class serves as a wrapper for the HttpContext class. At run time, you typically use an instance of the HttpContextWrapper class to call members on the HttpContext object.

Constructors

HttpContextBase()

Initializes the class for use by an inherited class instance. This constructor can only be called by an inherited class.

Properties

AllErrors

When overridden in a derived class, gets an array of errors (if any) that accumulated when an HTTP request was being processed.

AllowAsyncDuringSyncStages

When implemented in a derived class, gets or sets a value that indicates whether asynchronous operations are allowed during parts of ASP.NET request processing when they are not expected.

Application

When overridden in a derived class, gets the HttpApplicationState object for the current HTTP request.

ApplicationInstance

When overridden in a derived class, gets or sets the HttpApplication object for the current HTTP request.

AsyncPreloadMode

When implemented in a derived class, gets or sets an object that contains flags that pertain to asynchronous preload mode.

Cache

When overridden in a derived class, gets the Cache object for the current application domain.

CurrentHandler

When overridden in a derived class, gets the IHttpHandler object that represents the handler that is currently executing.

CurrentNotification

When overridden in a derived class, gets a RequestNotification value that indicates the HttpApplication event that is currently processing.

Error

When overridden in a derived class, gets the first error (if any) that accumulated when an HTTP request was being processed.

Handler

When overridden in a derived class, gets or sets the IHttpHandler object that is responsible for processing the HTTP request.

IsCustomErrorEnabled

When overridden in a derived class, gets a value that indicates whether custom errors are enabled for the current HTTP request.

IsDebuggingEnabled

When overridden in a derived class, gets a value that indicates whether the current HTTP request is in debug mode.

IsPostNotification

When overridden in a derived class, gets a value that indicates whether an HttpApplication event has finished processing.

IsWebSocketRequest

When implemented in a derived class, gets a value that indicates whether the request is an AspNetWebSocket connection request.

IsWebSocketRequestUpgrading

When implemented in a derived class, gets a value that indicates whether the connection is upgrading from an HTTP connection to an AspNetWebSocket connection.

Items

When overridden in a derived class, gets a key/value collection that can be used to organize and share data between a module and a handler during an HTTP request.

PageInstrumentation

When implemented in a derived class, gets a reference to the page-instrumentation service instance for this request.

PreviousHandler

When overridden in a derived class, gets the IHttpHandler object for the parent handler.

Profile

When overridden in a derived class, gets the ProfileBase object for the current user profile.

Request

When overridden in a derived class, gets the HttpRequest object for the current HTTP request.

Response

When overridden in a derived class, gets the HttpResponse object for the current HTTP response.

Server

When overridden in a derived class, gets the HttpServerUtility object that provides methods that are used when Web requests are being processed.

Session

When overridden in a derived class, gets the HttpSessionState object for the current HTTP request.

SkipAuthorization

When overridden in a derived class, gets or sets a value that specifies whether the UrlAuthorizationModule object should skip the authorization check for the current request.

ThreadAbortOnTimeout

When implemented in a derived class, gets or sets a value that specifies whether the ASP.NET runtime should call Abort() on the thread that is servicing this request when the request times out.

Timestamp

When overridden in a derived class, gets the initial timestamp of the current HTTP request.

Trace

When overridden in a derived class, gets the TraceContext object for the current HTTP response.

User

When overridden in a derived class, gets or sets security information for the current HTTP request.

WebSocketNegotiatedProtocol

When implemented in a derived class, gets the negotiated protocol that was sent from the server to the client for an AspNetWebSocket connection.

WebSocketRequestedProtocols

When implemented in a derived class, gets the ordered list of protocols that were requested by the client.

Methods

AcceptWebSocketRequest(Func<AspNetWebSocketContext,Task>)

When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function.

AcceptWebSocketRequest(Func<AspNetWebSocketContext,Task>, AspNetWebSocketOptions)

When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function and options object.

AddError(Exception)

When overridden in a derived class, adds an exception to the exception collection for the current HTTP request.

AddOnRequestCompleted(Action<HttpContextBase>)

When implemented in a derived class, raises a virtual event that occurs when the HTTP part of the request is ending.

ClearError()

When overridden in a derived class, clears all errors for the current HTTP request.

DisposeOnPipelineCompleted(IDisposable)

When implemented in a derived class, enables an object's Dispose() method to be called when the AspNetWebSocket connection part of this request is completed.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetGlobalResourceObject(String, String)

When overridden in a derived class, gets an application-level resource object based on the specified ClassKey and ResourceKey properties.

GetGlobalResourceObject(String, String, CultureInfo)

When overridden in a derived class, gets an application-level resource object based on the specified ClassKey and ResourceKey properties, and on the CultureInfo object.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLocalResourceObject(String, String)

When overridden in a derived class, gets a page-level resource object based on the specified VirtualPath and ResourceKey properties.

GetLocalResourceObject(String, String, CultureInfo)

When overridden in a derived class, gets a page-level resource object based on the specified VirtualPath and ResourceKey properties, and on the CultureInfo object.

GetSection(String)

When overridden in a derived class, gets the specified configuration section of the current application's default configuration.

GetService(Type)

When overridden in a derived class, returns an object for the current service type.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemapHandler(IHttpHandler)

When overridden in a derived class, specifies a handler for the request.

RewritePath(String)

When overridden in a derived class, rewrites the URL by using the specified path.

RewritePath(String, Boolean)

When overridden in a derived class, rewrites the URL by using the specified path and a value that specifies whether the virtual path for server resources is modified.

RewritePath(String, String, String)

When overridden in a derived class, rewrites the URL by using the specified path, path information, and query string information.

RewritePath(String, String, String, Boolean)

When overridden in a derived class, rewrites the URL by using the specified path, path information, query string information, and a value that specifies whether the client file path is set to the rewrite path.

SetSessionStateBehavior(SessionStateBehavior)

When overridden in a derived class, sets the type of session state behavior that is required to support an HTTP request.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

GetKeyedService<T>(IServiceProvider, Object)

Get service of type T from the IServiceProvider.

GetKeyedServices(IServiceProvider, Type, Object)

Get an enumeration of services of type serviceType from the IServiceProvider.

GetKeyedServices<T>(IServiceProvider, Object)

Get an enumeration of services of type T from the IServiceProvider.

GetRequiredKeyedService(IServiceProvider, Type, Object)

Get service of type serviceType from the IServiceProvider.

GetRequiredKeyedService<T>(IServiceProvider, Object)

Get service of type T from the IServiceProvider.

CreateAsyncScope(IServiceProvider)

Creates a new AsyncServiceScope that can be used to resolve scoped services.

CreateScope(IServiceProvider)

Creates a new IServiceScope that can be used to resolve scoped services.

GetRequiredService(IServiceProvider, Type)

Get service of type serviceType from the IServiceProvider.

GetRequiredService<T>(IServiceProvider)

Get service of type T from the IServiceProvider.

GetService<T>(IServiceProvider)

Get service of type T from the IServiceProvider.

GetServices(IServiceProvider, Type)

Get an enumeration of services of type serviceType from the IServiceProvider.

GetServices<T>(IServiceProvider)

Get an enumeration of services of type T from the IServiceProvider.

GetFakeLogCollector(IServiceProvider)

Gets the object that collects log records sent to the fake logger.

GetFakeRedactionCollector(IServiceProvider)

Gets the fake redactor collector instance from the dependency injection container.

Applies to