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,并使用HttpResponse对象将该 cookie 添加到页面的 HTTP 输出中。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)
   

适用于

另请参阅