Page.Response Page.Response Page.Response Page.Response Property

定義

取得與這個 HttpResponse 物件關聯的 Page 物件。Gets the HttpResponse object associated with the Page object. 此物件可讓您將 HTTP 回應資料傳送給用戶端,並包含該回應的相關資訊。This object allows you to send HTTP response data to a client and contains information about that response.

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

屬性值

與頁面關聯的目前 HttpResponseThe current HttpResponse associated with the page.

例外狀況

HttpResponse 物件不能使用。The HttpResponse object is not available.

範例

下列程式碼範例示範建立 cookie,並將它加入至網頁的 HTTP 輸出中,使用HttpResponse物件。The following code example demonstrates creating a cookie and adding it to the page's HTTP output by using the HttpResponse object.

HttpCookie MyCookie = new HttpCookie("LastVisit");
DateTime now = DateTime.Now;

MyCookie.Value = now.ToString();
MyCookie.Expires = now.AddHours(1);

Response.Cookies.Add(MyCookie);
   
Dim MyCookie As New HttpCookie("LastVisit")
Dim now As DateTime = DateTime.Now

MyCookie.Value = now.ToString()
MyCookie.Expires = now.AddHours(1)

Response.Cookies.Add(MyCookie)
   

適用於

另請參閱