ASP Request Object

The Request object provides access to all the information that is passed in a request from the browser to the server. This information is stored among five types of Request collections. Individual items in the collection are accessed via a unique key assigned to that item.

Property

TotalBytes Property
Specifies the total number of bytes sent in the body of the HTTP request.

Collection

ClientCertificate Collection
Contains the values of the client certification fields of the request. Used in SSL protocols.

Cookies Collection
Contains the values of the cookies sent in the request.

Form Collection
Contains the values of the <FORM> elements posted to a form using the POST method.

QueryString Collection
Contains the values of the HTTP query string, which are the statements in the URL that follow a question (?) mark.

ServerVariables Collection
Contains the values of server environmental variables. This allows access to the HTTP headers.

Method

BinaryRead(Count) Method
Retrieves the data that was sent to the server from the browser as part of a POST request, and returns the number of bytes read.

Tips & Hints

Looping Through Collections
You can use VBScript's "For Each - Next" control statement to quickly loop through all of the items in a collection.

<%
  'looping through items of the Request.QueryString collection
  For Each i In Request.QueryString
    Response.Write i & " = " & Request.QueryString(i) & "<br>"
  Next
%>
For example, if your URL was:
http://www.everything2.com/index.pl?type=e2node&node=HTML
then the above code would result in:
  type = e2node
  node = HTML
This comes in handy when processing a form with dozens of inputs.

Request(variable) Shortcut
All 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
This is a time saving shortcut while coding, but you have to be careful if you have more then one variable of the same name.
For example:
-------my_page.asp------
<form method="post" action="save_page.asp?save=yes">
  <input type="text" name="save">
  <input type="submit" name="submitForm" value="Submit">
</form>

------save_page.asp------
<%
  Response.Write Request("save")
%>
This will write "yes", not what the user typed in the form's text input field.

Optimizing Performance - Request(variable) vs. Request.Collection(variable)
A pitfall of using Request(variable) is that it takes the server longer to locate the item then if you use the fully qualified name, since the server has to sequentially search each collection for the item. While this is probably not going to make a difference on your personal web page, heavily loaded servers would notice a significant increase in efficiency by using the fully qualified name.


Back to ASP Objects


Resources:
http://www.devguru.com/
http://msdn.microsoft.com/

All code is my own (and may cause premature balding).

(v 3.0) indicates that this feature is only available with ASP Version 3.0, which shipped standard with IIS 5.0

Request is also the official magazine for members of Replay, which is a club that entitles you to discounts at Sam Goody's and Oncue.

Request delivers reviews of CD's and DVD's, as well as gives a good amount entertainment news. The most useful aspect of this magazine is that it shows you when and on what you can earn the most Replay points, which translates to free stuff for the reader.

Though it is mainly there to convince the reader to buy more music and video games, it's still worth scanning through occasionally, IMO, if only for the bonus replay points.

Re*quest" (r?-kw�xb5;st"), n. [OE. requeste, OF. requeste, F. requte, LL. requesta, for requisita, fr. L. requirere, requisitum, to seek again, ask for. See Require, and cf. Quest.]

1.

The act of asking for anything desired; expression of desire or demand; solicitation; prayer; petition; entreaty.

I will marry her, sir, at your request. Shak.

2.

That which is asked for or requested.

"He gave them their request."

Ps. cvi. 15.

I will both hear and grant you your requests. Shak.

3.

A state of being desired or held in such estimation as to be sought after or asked for; demand.

Knowledge and fame were in as great request as wealth among us now. Sir W. Temple.

Court of Requests. (a) A local tribunal, sometimes called Court of Consience, founded by act of Parliament to facilitate the recovery of small debts from any inhabitant or trader in the district defined by the act; -- now mostly abolished. (b) A court of equity for the relief of such persons as addressed the sovereign by supplication; -- now abolished. It was inferior to the Court of Chancery. [Eng.] Brande & C.

Syn. -- Asking; solicitation; petition; prayer; supplication; entreaty; suit.

 

© Webster 1913.


Re*quest" (r?-kw?st"), v. t. [imp. & p. p. Requested; p. pr. & vb. n. Requesting.] [Cf. OF. requester, F. requ≖ter.]

1.

To ask for (something); to express desire ffor; to solicit; as, to request his presence, or a favor.

2.

To address with a request; to ask.

I request you To give my poor host freedom. Shak.

Syn. -- To ask; solicit; entreat; beseech. See Beg.

 

© Webster 1913.

Log in or register to write something here or to contact authors.