|
|
|
|
|
|
|
|
|
|
|
Sometimes
we need to get information about the user, for example, the type of browser
s/he is using, environment variables. We also need to get some data about
the user himself/herself; like birthday, name, surname, etc. We use Request
object to perform these actions. It allows accessing any information that
is passed with an HTTP request, including the following:
A set of parameters passed with the POST method. A set of query parameters attached to the GET method. Cookies that are passed from a browser. Cookies allow a set of information to be associated with a user Client Certificates.
Form Cookies ServerVariabes ClientCertificate
Getting Information from HTML Forms In order to process HTML Forms, we can use ASP in one of the following ways:
An .asp file can create a from that posts information to ANOTHER .asp file. An .asp file can create a form that posts information to ITSELF, that is, to the .asp file that contains the form. QUERY_STRING variable can be used to evaluate the data coming from a form; however, ASP provides the QueryString Collection to make this information readily accessible. If the form method is POST, QueryString collection contains all the information passed as a parameter after the question mark in the URL. If the method is GET, the QueryString collection contains all the information passed in the form. Let's look at the
following example:
The following script uses the Request object to access these values: Welcome, <%= Request.QueryString("name")
%>.
The result is; Welcome Baris Uz. Your age is 24. If multiple entries exist for a variable, the object handles it in the following fashion: Assume that query string be: name=Baris&name=Emre&name=Ali then, Value of Request.QueryString("name")(1)
is Baris
This also supports
the Count property which returns the number of entries for the collection.
A similar property holds for Form collection. Posting Information to the Originating .asp File This can be used to control entries of the user for a form. For example, invalid telephone number, email address; incomplete filed determination, etc. Simply, we should give the .asp file name in the ACTION part of the Form. Using the Cookies Collection with the Request Object A cookie is a token that either a client browser sends to a web server or that a web server sends to a client browser. Cookies allow a set of information to be associated with a user. ASP can handle the values in the Cookies collection. The syntax is Request.Cookies("name")("key"). |
|
|
|
|
|
|