.NET Framework 类库
Page..::.Response 属性

更新:2007 年 11 月

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

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

语法

Visual Basic(声明)
<BrowsableAttribute(False)> _
Public ReadOnly Property Response As HttpResponse
Visual Basic (用法)
Dim instance As Page
Dim value As HttpResponse

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

属性值

类型:System.Web..::.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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

版本信息

.NET Framework

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

参考

标记 :


Page view tracker