HttpContextBase 类

定义

为包含有关单个 HTTP 请求的 HTTP 特定信息的类充当基类。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
继承
HttpContextBase
派生
实现

注解

类是一个抽象类, 它包含与HttpContext类相同的成员。 HttpContextBaseThe HttpContextBase class is an abstract class that contains the same members as the HttpContext class. 利用类, 您可以创建HttpContext类似于类的派生类, 但可以自定义该派生类并在 ASP.NET 管道之外工作。 HttpContextBaseThe 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.

HttpContextWrapper 类是从 HttpContextBase 类派生的。The HttpContextWrapper class derives from the HttpContextBase class. 类用作HttpContext类的包装。 HttpContextWrapperThe HttpContextWrapper class serves as a wrapper for the HttpContext class. 在运行时, 通常使用HttpContextWrapper类的实例来调用对象上的HttpContext成员。At run time, you typically use an instance of the HttpContextWrapper class to call members on the HttpContext object.

构造函数

HttpContextBase()

初始化该类供继承的类实例使用。Initializes the class for use by an inherited class instance. 此构造函数只能由继承的类调用。This constructor can only be called by an inherited class.

属性

AllErrors

在派生类中重写时,获取在处理 HTTP 请求时累积的错误(如果有)的数组。When overridden in a derived class, gets an array of errors (if any) that accumulated when an HTTP request was being processed.

AllowAsyncDuringSyncStages

在派生类中实现时,获取或设置一个值,该值指示 ASP.NET 请求处理过程中是否允许非预期的异步操作。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

当在派生类中重写时,获取当前 HTTP 请求的 HttpApplicationState 对象。When overridden in a derived class, gets the HttpApplicationState object for the current HTTP request.

ApplicationInstance

当在派生类中重写时,获取或设置当前 HTTP 请求的 HttpApplication 对象。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

在派生类中重写时,获取当前应用程序域的 Cache 对象。When overridden in a derived class, gets the Cache object for the current application domain.

CurrentHandler

在派生类中重写时,获取表示当前正在执行的处理程序的 IHttpHandler 对象。When overridden in a derived class, gets the IHttpHandler object that represents the handler that is currently executing.

CurrentNotification

在派生类中重写时,获取一个 RequestNotification 值,该值指示当前是否正在处理 HttpApplication 事件。When overridden in a derived class, gets a RequestNotification value that indicates the HttpApplication event that is currently processing.

Error

在派生类中重写时,获取在处理 HTTP 请求时累积的错误中的第一个错误(如果有)。When overridden in a derived class, gets the first error (if any) that accumulated when an HTTP request was being processed.

Handler

在派生类中重写时,获取或设置负责处理 HTTP 请求的 IHttpHandler 对象。When overridden in a derived class, gets or sets the IHttpHandler object that is responsible for processing the HTTP request.

IsCustomErrorEnabled

在派生类中重写时,获取一个值,该值指示是否为当前 HTTP 请求启用了自定义错误。When overridden in a derived class, gets a value that indicates whether custom errors are enabled for the current HTTP request.

IsDebuggingEnabled

在派生类中重写时,获取一个值,该值指示当前 HTTP 请求是否处于调试模式。When overridden in a derived class, gets a value that indicates whether the current HTTP request is in debug mode.

IsPostNotification

在派生类中重写时,获取一个值,该值指示 HttpApplication 事件是否已完成处理。When overridden in a derived class, gets a value that indicates whether an HttpApplication event has finished processing.

IsWebSocketRequest

在派生类中实现时,获取一个值,该值指示该请求是否是一个 AspNetWebSocket 连接请求。When implemented in a derived class, gets a value that indicates whether the request is an AspNetWebSocket connection request.

IsWebSocketRequestUpgrading

在派生类中实现时,获取一个值,该值指示连接是否从 HTTP 连接更新到 AspNetWebSocket 连接。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

在派生类中重写时,获取一个键/值集合,该集合在 HTTP 请求过程中可以用于在模块与处理程序之间组织和共享数据。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

在派生类中重写时,获取父处理程序的 IHttpHandler 对象。When overridden in a derived class, gets the IHttpHandler object for the parent handler.

Profile

在派生类中重写时,获取当前用户配置文件的 ProfileBase 对象。When overridden in a derived class, gets the ProfileBase object for the current user profile.

Request

当在派生类中重写时,获取当前 HTTP 请求的 HttpRequest 对象。When overridden in a derived class, gets the HttpRequest object for the current HTTP request.

Response

当在派生类中重写时,获取当前 HTTP 响应的 HttpResponse 对象。When overridden in a derived class, gets the HttpResponse object for the current HTTP response.

Server

在派生类中重写时,获取 HttpServerUtility 对象,该对象提供在处理 Web 请求时使用的方法。When overridden in a derived class, gets the HttpServerUtility object that provides methods that are used when Web requests are being processed.

Session

当在派生类中重写时,获取当前 HTTP 请求的 HttpSessionState 对象。When overridden in a derived class, gets the HttpSessionState object for the current HTTP request.

SkipAuthorization

在派生类中重写时,获取或设置一个值,该值指定 UrlAuthorizationModule 对象是否应跳过对当前请求的授权检查。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

在派生类中实现时,获取或设置一个值,该值指示 ASP.NET 运行时是否应在请求超时时,在为该请求提供服务的线程上调用 Abort()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

在派生类中重写时,获取当前 HTTP 请求的初始时间戳。When overridden in a derived class, gets the initial timestamp of the current HTTP request.

Trace

在派生类中重写时,获取当前 HTTP 响应的 TraceContext 对象。When overridden in a derived class, gets the TraceContext object for the current HTTP response.

User

在派生类中重写时,获取或设置当前 HTTP 请求的安全信息。When overridden in a derived class, gets or sets security information for the current HTTP request.

WebSocketNegotiatedProtocol

在派生类中实现时,为 AspNetWebSocket 连接获取从服务器发送到客户端的协商协议。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.

方法

AcceptWebSocketRequest(Func<AspNetWebSocketContext,Task>)

在派生类中实现时,接受使用指定用户函数的 AspNetWebSocket 请求。When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function.

AcceptWebSocketRequest(Func<AspNetWebSocketContext,Task>, AspNetWebSocketOptions)

在派生类中实现时,接受使用指定用户函数和选项对象的 AspNetWebSocket 请求。When implemented in a derived class, accepts an AspNetWebSocket request using the specified user function and options object.

AddError(Exception)

在派生类中重写时,将异常添加到当前 HTTP 请求的异常集合中。When overridden in a derived class, adds an exception to the exception collection for the current HTTP request.

AddOnRequestCompleted(Action<HttpContextBase>)

在派生类中实现时,引发在请求的 HTTP 部件结束时发生的虚拟事件。When implemented in a derived class, raises a virtual event that occurs when the HTTP part of the request is ending.

ClearError()

在派生类中重写时,清除当前 HTTP 请求的所有错误。When overridden in a derived class, clears all errors for the current HTTP request.

DisposeOnPipelineCompleted(IDisposable)

在派生类中实现时,使对象的 Dispose() 方法在此请求的 AspNetWebSocket 连接部分完成时能够被调用。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.

(继承自 Object)
GetGlobalResourceObject(String, String)

在派生类中重写时,根据指定的 ClassKeyResourceKey 属性,获取应用程序级别资源对象。When overridden in a derived class, gets an application-level resource object based on the specified ClassKey and ResourceKey properties.

GetGlobalResourceObject(String, String, CultureInfo)

在派生类中重写时,根据指定的 ClassKeyResourceKey 属性以及 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.

(继承自 Object)
GetLocalResourceObject(String, String)

在派生类中重写时,根据指定的 VirtualPathResourceKey 属性,获取一个页级别资源对象。When overridden in a derived class, gets a page-level resource object based on the specified VirtualPath and ResourceKey properties.

GetLocalResourceObject(String, String, CultureInfo)

在派生类中重写时,根据指定的 VirtualPathResourceKey 属性以及 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()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
RemapHandler(IHttpHandler)

在派生类中重写时,指定请求的处理程序。When overridden in a derived class, specifies a handler for the request.

RewritePath(String)

在派生类中重写时,使用指定的路径重写 URL。When overridden in a derived class, rewrites the URL by using the specified path.

RewritePath(String, Boolean)

在派生类中重写时,使用指定的路径和一个值重写 URL,该值指定是否修改服务器资源的虚拟路径。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)

在派生类中重写时,使用指定的路径、路径信息和查询字符串信息重写 URL。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)

在派生类中重写时,使用指定的路径、路径信息、查询字符串信息和一个值(该值指定是否将客户端文件路径设置为重写路径)重写 URL。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)

在派生类中重写时,设置支持 HTTP 请求所必需的会话状态行为的类型。When overridden in a derived class, sets the type of session state behavior that is required to support an HTTP request.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于