.NET Framework 类库
Page.Response 属性

获取与该 Page 对象关联的 HttpResponse 对象。该对象使您得以将 HTTP 响应数据发送到客户端,并包含有关该响应的信息。

命名空间:System.Web.UI
程序集:System.Web(在 system.web.dll 中)

语法

Visual Basic(声明)
Public ReadOnly Property Response As HttpResponse
Visual Basic(用法)
Dim instance As Page
Dim value As HttpResponse

value = instance.Response
C#
public HttpResponse Response { get; }
C++
public:
property HttpResponse^ Response {
    HttpResponse^ get ();
}
J#
/** @property */
public HttpResponse get_Response ()
JScript
public function get Response () : HttpResponse

属性值

当前与该页关联的 HttpResponse
异常

异常类型条件

HttpException

HttpResponse 对象不可用。

示例

下面的代码示例演示如何通过使用 HttpResponse 对象创建 Cookie,并将其添加到页的 HTTP 输出。

Visual Basic
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)
   
C#
HttpCookie MyCookie = new HttpCookie("LastVisit");
DateTime now = DateTime.Now;

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

Response.Cookies.Add(MyCookie);
   
J#
HttpCookie myCookie = new HttpCookie("LastVisit");
DateTime now = DateTime.get_Now();

myCookie.set_Value(now.ToString());
myCookie.set_Expires(now.AddHours(1));

get_Response().get_Cookies().Add(myCookie);
JScript
var myCookie : HttpCookie = new HttpCookie("LastVisit")
var now : DateTime = DateTime.Now

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

Response.Cookies.Add(myCookie)
   
平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0
请参见

标记 :


Page view tracker