Wednesday, April 18, 2007

ASP Request Object

As we all know, web is all about Request and Response. You send your request to Webserver and Server sends you back the Response.

Server side programming has these 2 activities wrapped in to object called Request and Response object which help us to read or manipulate those object.

The Request Object receives the values that the client's browser passed to the server during an HTTP request.

Request Object has several namevalue "collections".
  • ClientCertificate: The values of fields stored in the client certificate that is sent in the HTTP request.
  • Cookies: The values of cookies sent in the HTTP request.
  • Form: The values of form elements in the HTTP request body.
  • QueryString: The values of variables in the HTTP query string.
  • ServerVariables: The values of predetermined server/environment variables.
The syntax is: Request[.collectionpropertymethod](variable)

All request object variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order:
  1. QueryString
  2. Form
  3. Cookies
  4. ClientCertificate
  5. ServerVariables

If a variable with the same name exists in more than one collection, the Request object returns the first instance encountered. It is strongly recommended that, when referring to members of the ServerVariables collection, the full name be used. For example, rather than Request("AUTH_USER") use Request.ServerVariables("AUTH_USER").

0 comments: