HttpContext.Response 属性

定义

获取当前 HTTP 响应的 HttpResponse 对象。Gets the HttpResponse object for the current HTTP response.

public:
 property System::Web::HttpResponse ^ Response { System::Web::HttpResponse ^ get(); };
public System.Web.HttpResponse Response { get; }
member this.Response : System.Web.HttpResponse
Public ReadOnly Property Response As HttpResponse

属性值

HttpResponse

当前 HTTP 响应的 HttpResponseThe HttpResponse for the current HTTP response.

例外

Web 应用程序正在 IIS 7 的“集成”模式下运行。The Web application is running under IIS 7 in Integrated mode.

注解

Response属性提供对类的属性和方法的编程访问 HttpResponseThe Response property provides programmatic access to the properties and methods of the HttpResponse class. 由于 ASP.NET 页包含对 System.Web 包含) 类 (命名空间的默认引用 HttpContext ,因此可以 HttpContext 在不使用对的完全限定类引用的情况下引用 .aspx 页上的成员 HttpContextBecause ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without using the fully qualified class reference to HttpContext. 例如,可以使用 Response.Write("some output") 将输出写入 HTTP 输出流。For example, you can use Response.Write("some output") to write output to an HTTP output stream. 但是,如果要 HttpResponse 从 ASP.NET 代码隐藏模块使用的成员,则必须在模块中包括对命名空间的引用, System.Web 并包含对当前活动的请求/响应上下文以及要使用的类的完全限定引用 System.WebHowever, if you want to use the members of HttpResponse from an ASP.NET code-behind module, you must include a reference to the System.Web namespace in the module and a fully qualified reference to the currently active request/response context and the class in System.Web that you want to use. 例如,在代码隐藏页中,必须指定完全限定的名称 HttpContext.Current.Response.Write("some output")For example, in a code-behind page you must specify the fully qualified name HttpContext.Current.Response.Write("some output").

适用于