Programming Microsoft ASP.NET 4 - Dino Esposito [345]
Headers
Gets a name-value collection filled with all the header values in the request.
InputStream
Gets a Stream object representing the contents of the incoming HTTP content body.
Params
Gets a name-value collection that is a union of four other similar collections: QueryString, Form, ServerVariables, and Cookies.
QueryString
Gets a name-value collection containing all the query string variables sent by the client.
ServerVariables
Gets a name-value collection filled with a collection of Web server–defined variables.
UserHostAddress
Gets the Internet Protocol (IP) address of the remote client.
UserHostName
Gets the Domain Name System (DNS) name of the remote client.
UserLanguages
Gets an array of strings denoting the list of the languages accepted by the client for the specified request. The languages are read from the Accept-Language header.
The Params collection combines four different but homogeneous collections—QueryString, Form, ServerVariables, and Cookies—and it replicates the information contained in each of them. The collections are added in the following order: QueryString, Form, Cookies, and finally ServerVariables.
Information About the Connection
Table 16-14 lists the properties that relate to the open connection.
Table 16-14. Properties Describing the Connection
Property
Description
ApplicationPath
Gets the virtual path of the current application.
IsAuthenticated
Indicates whether or not the user has been authenticated.
IsLocal
Indicates if it is a local request.
IsSecureConnection
Indicates whether the connection is taking place over a Secure Sockets Layer (SSL) using HTTPS.
LogonUserIdentity
Gets an object representing the Windows identity of the current user as logged at the IIS gate.
Path
Gets the virtual path of the current request.
PathInfo
Gets additional path information for the requested resource, if any. The property returns any text that follows the URL.
PhysicalApplicationPath
Gets the file system path of the current application’s root directory.
PhysicalPath
Gets the physical file system path corresponding to the requested URL.
RawUrl
Gets the raw URL of the current request.
Url
Gets the Uri object that represents the URL of the current request.
UrlReferrer
Gets the Uri object that represents the URL from which the current request originated.
The Uri class provides an object representation of a Uniform Resource Identifier (URI)—a unique name for a resource available on the Internet. The Uri class provides easy access to the parts of the URI as well as properties and methods for checking host, loopback, ports, and DNS.
The server variables set in the ServerVariables collection are decided by the run-time environment that processes the request. The information packed in the collection is, for the most part, excerpted from the HTTP worker request object; another part contains Web server–specific information. The ServerVariables collection is just a friendly name/value model to expose that information.
Methods of the HttpRequest Class
Table 16-15 lists all methods exposed by the HttpRequest class.
Table 16-15. HttpRequest Methods
Method
Description
BinaryRead
Performs a binary read from the current input stream. The method lets you specify the number of bytes to read and returns an array of bytes. The method is provided for compatibility with ASP. ASP.NET applications should read from the stream associated with the InputStream property.
MapImageCoordinates
Maps an incoming image-field form parameter to x/y coordinate values.
MapPath
Maps the specified virtual path to a physical path on the Web server.
SaveAs
Saves the current request to a file disk with or without headers. This method is especially useful for debugging.
ValidateInput
Performs a quick, nonexhaustive check to find potentially dangerous