O'Reilly logo

ASP.NET in a Nutshell by Matthew MacDonald, G. Andrew Duthie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. The HttpResponse Class

Just as the HttpRequest class covered in Chapter 16 is the replacement for the classic ASP intrinsic Request object, the HttpResponse class is ASP.NET’s replacement for ASP’s intrinsic Response object. Like the HttpRequest class, the HttpResponse class instance for a given ASP.NET page is exposed as a property (the Response property) of the Page class (from which all pages are derived), so code for the HttpResponse class is the same as in classic ASP. For those of you with classic ASP applications that migrate to ASP.NET, this class will save you a lot of work.

The HttpResponse class controls a variety of factors related to ASP.NET’s response to a given HTTP request and provides access to the output stream of the response, allowing the writing of text or binary content to the client browser programmatically. The HttpResponse class provides access to this functionality through its properties, collections, and methods, which are shown in Table 17-1.

The control over page output that the HttpResponse class provides includes the character set used and encoding of the response, as well as whether the response is buffered and sent all at once (the default) or sent as output is processed. Methods of the HttpResponse class provide granular control over output sent to the browser, including sending binary or text content and sending HTTP headers and cookies to the client.

Note that several properties and methods exposed by the Response object in classic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required