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

属性值

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

异常

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

注解

Response 属性提供对 HttpResponse 类的属性和方法的编程访问。The Response property provides programmatic access to the properties and methods of the HttpResponse class. 由于 ASP.NET 页包含对 System.Web 命名空间(包含 HttpContext 类)的默认引用,因此你可以在不使用对 HttpContext的完全限定类引用的情况下引用 .aspx 页上 HttpContext 的成员。Because 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. 但是,如果要从 ASP.NET 代码隐藏模块使用 HttpResponse 的成员,则必须在模块中包含对 System.Web 命名空间的引用,并包含对当前活动的请求/响应上下文和中的类的完全限定引用 System.Web要使用的。However, 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").

适用于