Name

Response

Synopsis

HttpResponse  = Page.Response

Returns an instance of the HttpResponse class that stores information about the response and allows us to send HTTP response data to a browser. It’s the equivalent of the ASP intrinsic Response object. For information on the HttpResponse class, see Chapter 17.

Parameters

HttpResponse

An object of type HttpResponse that receives the instance of the HttpResponse class.

Example

The following example uses the Response property of the page object to set the ContentType property of the HttpResponse class to text/xml. Setting this property will result in the output of the page being displayed as XML markup in Internet Explorer 5.0 or above.

Sub Page_Load(  )
   Response.ContentType = "text/xml"
   Message.Text = "This page will be displayed as XML in " & _
      "Internet Explorer 5.0 or above."
End Sub

Notes

As with the Application and Cache properties, while you can retrieve a local reference to the HttpResponse instance associated with the request, it is more common to access this instance directly through the Request property, as shown in this example.

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.