Académique Documents
Professionnel Documents
Culture Documents
The Request object retrieves the values that the client browser passed to the server during
an HTTP request.
Syntax
Request[.collection|property|method](variable)
Collections
ClientCertificate The values of fields stored in the client certificate that is sent in
the HTTP request.
Properties
Methods
BinaryRead Retrieves data sent to the server from the client as part of a
POST request.
Variable parameters are strings that specify the item to be retrieved from a collection or to be
used as input for a method or property. For more information about the variable parameter,
see the individual collection descriptions.
Remarks
If the specified variable is not in one of the preceding five collections, the Request object
returns EMPTY.
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
If a variable with the same name exists in more than one collection, the Request object
returns the first instance that the object encounters.
It is strongly recommended that when referring to members of a collection the full name be
used. For example, rather than Request.(AUTH_USER) use
Request.ServerVariables(AUTH_USER). This will allow the server to locate the item more
quickly.
See Also
Response Object
ClientCertificate
The ClientCertificate collection holds fields of keys and values from a security certificate that
the client browser passes to the Web server. These fields are specified in the X.509 version 3
standard for public key certificates. Because X.509 is not an official standard, you may notice
differences among certificates obtained from certificate authorities. See World Wide Web
Consortium Web site for an article titled X509 Certificate.
In order to populate the fields of the ClientCertificate collection, both the Web server and
the client browser must support the SSL3.0/PCT1.0 protocol. The Web site must have SSL
enabled and request client certificates. Once SSL is enabled, the URL of the Web site will start
with "https://" instead of "http://". The client browser must be capable of sending a
certificate. If no certificate is sent, the ClientCertificate collection returns EMPTY.
To configure your Web server to request client certificates, see Setting Up SSL on Your Server.
To read the values in each field of the ClientCertificate collection, pass in a key name and
optional subfield name.
Syntax
Request.ClientCertificate( Key[SubField] )
Parameters
Key
Specifies the name of the certification field to retrieve. A client certificate consists of
the following fields.
Value Meaning
Subject A string that contains a list of subfield values. The subfield values
contain information about the subject of the certificate. If this value
is specified without a SubField, the ClientCertificate collection
returns a comma-separated list of subfields. For example, C=US,
O=Msft, and so on.
ValidFrom A date specifying when the certificate becomes valid. This date
follows VBScript format and varies with international settings. For
example, in the U.S., 9/26/96 11:59:59 PM. The year value is
displayed as a four-digit number.
ValidUntil A date specifying when the certificate expires. The year value is
displayed as a four-digit number.
SubField
An optional parameter you can use to a retrieve an individual field in either the
Subject or Issuer keys. This parameter is added to the Key parameter as a suffix. For
example, IssuerO or SubjectCN. The following table lists some common SubField
values.
Value Meaning
C Specifies the name of the country/region of origin.
CN Specifies the common name of the user. (This subfield is only used
with the Subject key.)
L Specifies a locality.
SubField values other than those listed in the preceding table can be identified by their
ASN.1 Object Identifier (OID). The format of the OID is a list of numbers separated by
a period (.). A list of OIDs for your certificate can be obtained from the authority that
issued your certificate.
Example
You can iterate through the keys of the ClientCertificate collection. This is
demonstrated in the following example.
<%
Next
%>
The following example retrieves the common name of the company that issued the
client certificate.
The following example displays the expiration date of the client certificate.
<%
Const ceCertPresent = 1
Const ceUnrecognizedIssuer = 2
If Request.ClientCertificate("Flags") =
ceUnrecognizedIssuer Then
End If
%>
The following example displays all the fields of a client certificate.
Issuer: <%=Request.ClientCertificate("Issuer")%><br>
Subject: <%=Request.ClientCertificate("Subject")%><br>
<%=hex(asc(mid(cer,x,1)))%>
Cookies
The Cookies collection enables you to retrieve the values of the cookies sent in an HTTP
request.
Syntax
Request.Cookies(cookie)[(key)|.attribute]
Parameters
cookie
Specifies the cookie whose value should be retrieved.
key
An optional parameter used to retrieve subkey values from cookie dictionaries.
attribute
Specifies information about the cookie itself. The attribute parameter can be the
following.
Name Description
HasKeys Read-only. Specifies whether the cookie contains keys.
Remarks
You can access the subkeys of a cookie dictionary by including a value for key. If a
cookie dictionary is accessed without specifying key, all of the keys are returned
as a single query string. For example, if MyCookie has two keys, First and
Second, and you do not specify either of these keys in a call to Request.Cookies,
the following string is returned.
First=firstkeyvalue&Second=secondkeyvalue
If two cookies with the same name are sent by the client browser,
Request.Cookies returns the one with the deeper path structure. For example, if
two cookies had the same name but one had a path attribute of /www/ and the
other of /www/home/, the client browser would send both cookies to the
/www/home/ directory, but Request.Cookies would only return the second
cookie.
You can iterate through all the cookies in the Cookie collection, or all the keys in a
cookie. However, iterating through keys on a cookie that does not have keys will
not produce any output. You can avoid this situation by first checking to see
whether a cookie has keys by using the .HasKeys syntax. This is demonstrated in
the following example:
<%
If Request.Cookies(strKey).HasKeys Then
Request.Cookies(strKey)(strSubKey) &
"<BR>"
Next
End If
Next
%>
Example
Note Cookies are described in detail in the HTTP state management specification,
which is available at the World Wide Web Consortium Web site.
Applies To
Request Object
Form
The Form collection retrieves the values of form elements posted to the HTTP request body,
with a form using the POST method.
Syntax
Request.Form(element)[(index)|.Count]
Parameters
element
The name of the form element from which the collection is to retrieve values.
index
An optional parameter that enables you to access one of multiple values for a
parameter. It can be any integer in the range 1 to Request.Form(parameter).Count.
Remarks
The Form collection is indexed by the names of the parameters in the request body.
The value of Request.Form(element) is an array of all the values of element that
occur in the request body. You can determine the number of values of a parameter by
calling Request.Form(element).Count. If a parameter does not have multiple values
associated with it, the count is 1. If the parameter is not found, the count is 0.
To reference a single value of a form element that has multiple values, you must
specify a value for index. The index parameter may be any number between 1 and
Request.Form(element).Count. If you reference one of multiple form parameters
without specifying a value for index, the data is returned as a comma-delimited string.
When you use parameters with Request.Form, the Web server parses the HTTP
request body and returns the specified data. If your application requires unparsed data
from the form, you can access it by calling Request.Form without any parameters.
Note When using ASP and posting large amounts of data beyond 100 kilobytes,
Request.Form cannot be used. If your application requires posting data greater than
this limit, a component can be written which uses the Request.BinaryRead method.
You can iterate through all the data values in a form request. For example, if a user
filled out a form by specifying two values - Chocolate and Butterscotch - for the
FavoriteFlavor element, you could retrieve those values by using the following script.
<%
For i = 1 To Request.Form("FavoriteFlavor").Count
Next
%>
Chocolate
Butterscotch
You can use this technique to display the parameter name, as shown in the following
script:
<%
Request.Form(FavoriteFlavor) = <%=
Request.Form("FavoriteFlavor")(i)_
%> <BR>
Request.Form(FavoriteFlavor) = Chocolate
Request.Form(FavoriteFlavor) = Butterscotch
Example
<OPTION>Vanilla
<OPTION>Strawberry
<OPTION>Chocolate
<OPTION>Rocky Road</SELECT>
</FORM>
From that form, the following request body might be sent:
firstname=James&flavor=Rocky+Road
Note If your form includes multiple objects with the same name (for example, HTML
SELECT tags), the item in the form collection will be a comma-delimited list of all the
selected values.
Applies To
Request Object
See Also
ClientCertificate, Cookies, QueryString, ServerVariables
QueryString
The QueryString collection retrieves the values of the variables in the HTTP query string. The
HTTP query string is specified by the values following the question mark (?). Several different
processes can generate a query string. For example, the anchor tag
generates a variable named string with the value "this is a sample." Query strings are also
generated by sending a form, or by a user typing a query into the address box of the browser.
Syntax
Request.QueryString(variable)[(index)|.Count]
Parameters
variable
Specifies the name of the variable in the HTTP query string to retrieve.
index
An optional parameter that enables you to retrieve one of multiple values for variable.
It can be any integer value in the range 1 to Request.QueryString(variable).Count.
Remarks
To reference a QueryString variable in one of multiple data sets, you specify a value
for index. The index parameter can be any value between 1 and
Request.QueryString(variable).Count. If you reference one of multiple
QueryString variables without specifying a value for index, the data is returned as a
comma-delimited string.
When you use parameters with Request.QueryString, the server parses the
parameters sent to the request and returns the specified data. If your application
requires unparsed QueryString data, you can retrieve it by calling
Request.QueryString without any parameters.
You can use an iterator to loop through all the data values in a query string. For
example, if the following request is sent
http://localhost/script/directory/NAMES.ASP?
Q=Fred&Q=Sally
and Names.asp contained the following script,
---NAMES.ASP---
<%
Next
%>
Fred
Sally
The preceding script could also have been written using Count.
<%
For i = 1 To Request.QueryString("Q").Count
Next
%>
Example
/scripts/directory-lookup.asp?name=fred&age=22
results in the following QUERY_STRING value:
name=fred&age=22.
The QueryString collection would then contain two members, name and age. You
can then use the following script:
Applies To
Request Object
See Also
ServerVariables
The ServerVariables collection retrieves the values of predetermined environment variables.
Syntax
Parameters
Variable Description
Remarks
If a client sends a header other than those specified in the preceding table, you can
retrieve the value of that header by prefixing the header name with HTTP_ in the call to
Request.ServerVariables. For example, if the client sends the header:
SomeNewHeader:SomeNewValue
Example
<HTML>
</HTML>
This example uses the VBScript For Each loop to iterate through each existing server
variable name. Some will be empty if you have Anonymous Access enabled. The following
script prints out all of the server variables in a table:
<TABLE BORDER="1">
<TR><TD><B>Server
Variable</B></TD><TD><B>Value</B></TD></TR>
<TR>
</TR>
</TABLE>
This example inserts the name of the server into a hyperlink.
Link to MyPage.asp
</A>
TotalBytes
The TotalBytes property specifies the total number of bytes the client sent in the body of the
request. This property is Read-only.
Syntax
Counter = Request.TotalBytes
Parameters
Counter
Specifies a variable to receive the total number of bytes that the client sends in the
request.
Example
The following script sets a variable equal to the total number of bytes included in a request
object.
<%
Dim bytecount
bytecount = Request.TotalBytes
%>