Export (0) Print
Expand All

Page.Response Property

Gets the HttpResponse object associated with the Page. This object allows you to send HTTP response data to a client and contains information about that response.

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

Property Value

The current Response object associated with the page.

Exceptions

Exception Type Condition
HttpException The Response object is not available.

Example

The following examples demonstrates creating a cookie and adding it to the page's HTTP output by using the Response object.

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

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

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace | HttpResponse

Show:
© 2014 Microsoft