
318
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 16HttpRequest Class
16
The HttpRequest Class
The HttpRequest class is ASP.NET’s replacement for ASP’s Request intrinsic
object. Because the
HttpRequest class instance for a given ASP.NET page is
exposed as the Request property of the
Page class (from which all pages are
derived), you can code to the
HttpRequest class just as you did in ASP. Thus, your
existing ASP code will be that much easier to migrate.
The
HttpRequest class is used to access information related to a particular HTTP
request made by a web client. The
HttpRequest class provides access to this infor-
mation through its properties, collections, and methods.
Each HTTP request from a client consists of an HTTP header and, optionally, a
body. The header and body are separated by a blank line. The code following
shows a typical HTTP request (without a body):
GET /ASPdotNET_iaN/Chapter_16/showHTTP.aspx HTTP/1.0
Connection: Keep-Alive
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
Accept-Charset: iso-8859-1,*,utf-8
Accept-Encoding: gzip
Accept-Language: en
Host: localhost
User-Agent: Mozilla/4.08 [en] (WinNT; U ;Nav)
The first line of the HTTP header contains the request type, followed by a
space, followed by the requested URL (URI), another space, and the HTTP
version number. In the previous example, ...