|
The Request Object
When a browser asks for a page from a server, it is called a request. The ASP Request object is used to get information from the user. Its collections, properties, and methods are described below:
Collections
Description
|
ClientCertificate
|
Contains all the field values stored in the client certificate
|
Cookies
|
Contains all the cookie values sent in a HTTP request
|
Form
|
Contains all the form (input) values from a form that uses the post method Syntax: Request.Form(element)[(index).Count]
Element is required Index is Optional
Element is the name of the Form <input> field, List value, option button, checkbox you supply in your NOF generated form.
Index specifies one or more values for a parameter. From 1 to Request.Form(parameter).Count. For Example: You can have the same name for two different <input> fields. Each value is retained during submission and both values can be requested. You could retrieve those values in a fashion similar to this. A form contains the <input> field name "username" twice on the same form. One donates First Choice the second donates second choice. Example: <% Response.write "Your choices for a Username are:<br>" for i=1 to Request.Form("username").Count Response.Write(Request.Form("username")(i) & "<br />") next ' from here you could open a db and look for duplicate ' values for both indexes. If the first choice is not available ' you can search for the second choice and dim a variable ' to contain the one that is not found %>
|
QueryString
|
Contains all the variable values in a HTTP query string
The HTTP query string is specified by the values following the question mark (?), for example:
<a href= "www.kujawas.net/myasp.asp?name=Michael Kujawa">What is my Name</a>
The html fragment above creates a variable named "name" with the value "Michael Kujawa". Example: <% Dim xx xx = Request.QueryString("name") Response.Write "Your name is" & xx %>
or
<% Dim xx xx = Request.QueryString(1) Response.Write "Your name is" & xx %>
The Output page would have the data
Your name is Michael Kujawa
Query strings can also be created by form submission using the "GET" method, or by a user typing a url with a query in the address bar of your default internet browser application
Using Querystrings with form submission has negatives as the information can be captured through the address bar. If your forms contain sensitive information use the POST method.
Syntax: Request.QueryString(variable)[(index).Count] Variable is required. It donates the name of the variable in the HTTP query string.
Index is again option. It acts the same way as the Form request. As you can have multiple variables with the same name that can be looped together to query data or write response data.
|
ServerVariables
|
Contains all the server variable values held by the server Click the link to the left to see all variables and possible uses. For Examples and syntax Click Here
|
|
Properties
Description
|
TotalBytes
|
Returns the total number of bytes the client sent in the body of the request. The property is a read-only
syntax: Request.TotalBytes You can use this in conjunction with the BinaryRead property to get the total bytes for the Binary Object
|
|
Methods
Description
|
BinaryRead
|
Retrieves the data sent to the server from the client as part of a post request and stores it in a safe array
Note: Once you call a Binaryread request, if you call a request.form you will generate an error.
Syntax: Request.BinaryRead
Example:
<% dim file,size size=Request.TotalBytes file=Request.BinaryRead(size) %>
|
|
|