HttpContext.Response HttpContext.Response HttpContext.Response HttpContext.Response Property

定義

取得目前 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 頁面上,而不需使用完整的類別參考給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.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").

適用於