Export (0) Print
Expand All

HttpContextBase Class

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

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public abstract class HttpContextBase : IServiceProvider

The HttpContextBase type exposes the following members.

  NameDescription
Protected methodHttpContextBaseInitializes the class for use by an inherited class instance. This constructor can only be called by an inherited class.
Top

  NameDescription
Public propertyAllErrorsWhen overridden in a derived class, gets an array of errors (if any) that accumulated when an HTTP request was being processed.
Public propertyAllowAsyncDuringSyncStagesWhen 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.
Public propertyApplicationWhen overridden in a derived class, gets the HttpApplicationState object for the current HTTP request.
Public propertyApplicationInstanceWhen overridden in a derived class, gets or sets the HttpApplication object for the current HTTP request.
Public propertyAsyncPreloadModeWhen implemented in a derived class, gets or sets an object that contains flags that pertain to asynchronous preload mode.
Public propertyCacheWhen overridden in a derived class, gets the Cache object for the current application domain.
Public propertyCurrentHandlerWhen overridden in a derived class, gets the IHttpHandler object that represents the handler that is currently executing.
Public propertyCurrentNotificationWhen overridden in a derived class, gets a RequestNotification value that indicates the HttpApplication event that is currently processing.
Public propertyErrorWhen overridden in a derived class, gets the first error (if any) that accumulated when an HTTP request was being processed.
Public propertyHandlerWhen overridden in a derived class, gets or sets the IHttpHandler object that is responsible for processing the HTTP request.
Public propertyIsCustomErrorEnabledWhen overridden in a derived class, gets a value that indicates whether custom errors are enabled for the current HTTP request.
Public propertyIsDebuggingEnabledWhen overridden in a derived class, gets a value that indicates whether the current HTTP request is in debug mode.
Public propertyIsPostNotificationWhen overridden in a derived class, gets a value that indicates whether an HttpApplication event has finished processing.
Public propertyIsWebSocketRequestWhen implemented in a derived class, gets a value that indicates whether the request is an AspNetWebSocket connection request.
Public propertyIsWebSocketRequestUpgradingWhen implemented in a derived class, gets a value that indicates whether the connection is upgrading from an HTTP connection to an AspNetWebSocket connection.
Public propertyItemsWhen 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.
Public propertyPageInstrumentationWhen implemented in a derived class, gets a reference to the page-instrumentation service instance for this request.
Public propertyPreviousHandlerWhen overridden in a derived class, gets the IHttpHandler object for the parent handler.
Public propertyProfileWhen overridden in a derived class, gets the ProfileBase object for the current user profile.
Public propertyRequestWhen overridden in a derived class, gets the HttpRequest object for the current HTTP request.
Public propertyResponseWhen overridden in a derived class, gets the HttpResponse object for the current HTTP response.
Public propertyServerWhen overridden in a derived class, gets the HttpServerUtility object that provides methods that are used when Web requests are being processed.
Public propertySessionWhen overridden in a derived class, gets the HttpSessionState object for the current HTTP request.
Public propertySkipAuthorizationWhen 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.
Public propertyThreadAbortOnTimeoutWhen implemented in a derived class, gets or sets a value that specifies whether the ASP.NET runtime should call Thread.Abort on the thread that is servicing this request when the request times out.
Public propertyTimestampWhen overridden in a derived class, gets the initial timestamp of the current HTTP request.
Public propertyTraceWhen overridden in a derived class, gets the TraceContext object for the current HTTP response.
Public propertyUserWhen overridden in a derived class, gets or sets security information for the current HTTP request.
Public propertyWebSocketNegotiatedProtocolWhen implemented in a derived class, gets the negotiated protocol that was sent from the server to the client for an AspNetWebSocket connection.
Public propertyWebSocketRequestedProtocolsWhen implemented in a derived class, gets the ordered list of protocols that were requested by the client.
Top

  NameDescription
Public methodAcceptWebSocketRequest(Func<AspNetWebSocketContext, Task>)When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function.
Public methodAcceptWebSocketRequest(Func<AspNetWebSocketContext, Task>, AspNetWebSocketOptions)When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function and options object.
Public methodAddErrorWhen overridden in a derived class, adds an exception to the exception collection for the current HTTP request.
Public methodAddOnRequestCompletedWhen implemented in a derived class, raises a virtual event that occurs when the HTTP part of the request is ending.
Public methodClearErrorWhen overridden in a derived class, clears all errors for the current HTTP request.
Public methodDisposeOnPipelineCompletedWhen implemented in a derived class, enables an object's Dispose method to be called when the AspNetWebSocket connection part of this request is completed.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetGlobalResourceObject(String, String)When overridden in a derived class, gets an application-level resource object based on the specified ClassKey and ResourceKey properties.
Public methodGetGlobalResourceObject(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.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLocalResourceObject(String, String)When overridden in a derived class, gets a page-level resource object based on the specified VirtualPath and ResourceKey properties.
Public methodGetLocalResourceObject(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.
Public methodGetSectionWhen overridden in a derived class, gets the specified configuration section of the current application's default configuration.
Public methodGetServiceWhen overridden in a derived class, returns an object for the current service type.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemapHandlerWhen overridden in a derived class, specifies a handler for the request.
Public methodRewritePath(String)When overridden in a derived class, rewrites the URL by using the specified path.
Public methodRewritePath(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.
Public methodRewritePath(String, String, String)When overridden in a derived class, rewrites the URL by using the specified path, path information, and query string information.
Public methodRewritePath(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.
Public methodSetSessionStateBehaviorWhen overridden in a derived class, sets the type of session state behavior that is required to support an HTTP request.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft