次の方法で共有


Page.Response プロパティ

Page に関連付けられている HttpResponse オブジェクトを取得します。このオブジェクトを使用することにより、HTTP 応答データをクライアントに送り、この応答に関する情報を格納できます。

Public ReadOnly Property Response As HttpResponse
[C#]
public HttpResponse Response {get;}
[C++]
public: __property HttpResponse* get_Response();
[JScript]
public function get Response() : HttpResponse;

プロパティ値

ページに関連付けられている現在の Response オブジェクト。

例外

例外の種類 条件
HttpException Response オブジェクトが使用できません。

使用例

Response オブジェクトを使用して、cookie を作成し、それをページの HTTP 出力に追加する方法の例を次に示します。

 
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);
   

[C++] 
HttpCookie* MyCookie = new HttpCookie(S"LastVisit");
DateTime now = DateTime::Now;

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

Response->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 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

Page クラス | Page メンバ | System.Web.UI 名前空間 | HttpResponse