|
The request object has a lot of different
collections, properties, and events methods. The outline is as follows:
- Properties
- Collections
- ClientCertificate
- Cookies
- Form
- QueryString
- ServerVariables
- Methods
The TotalBytes Property returns the total
number of bytes that have been posted to the server. This value is read
only. This is not used much however it does come in handy sometimes.
The first too collections that we will look at are
the Form and Querystring collections. These are the most
commonly used in ASP although the others are very useful once you get the
hang of things.
Both the Form and the QueryString
collections are related to the <Form> tags in HTML. When using the
form tag in HTML there is a property called method. Method has two values
associated with it: GET and POST. When using the GET you need to retrieve
the value sent from the form using the QueryString collection. When POST
is used you need to use the Form collection. The QueryString collection
however is very useful for a number of things other than just retrieving
the form information. An example is if you look at the address of this
page you will see default.asp?ID=8. The ?ID=8 is a querystring and it is
used to retrieve the article you requested, but more on that later.
The Cookies collection is pretty straight
forward. It allows you to get and set values for a cookie that is stored
on the clients machine. Cookies are not evil as some people have said they
are. They are an efficient and safe way for a web programmer to store
information about a user. Lets say you wanted to allow the user to set the
background color on your web page so that every time they come to the site
they see their chosen colors. How would you know it was them and what
their settings are. There are two ways: 1) Have them log in every time
and then store their info in a database that you pull it from. 2) Store
a cookie with this information in it on their machine.
The ClientCertificates Collection is very
similar to the Cookies collection however it is used to gain information
about the certificate that the user connected with. This is used in secure
sites so I will not expand upon it very much here.
The ServerVariables collection is a very
useful collection that allows you to gain access to a number of variables
relating to the server and the request. The variables are sent to the
server in the form of an HTTP header which is information hidden for the
user. I will show you in the examples how to retreive these value and also
put them to use.
The BinaryRead method allows you to read in
binary format the information set to the server. This method is not used
much unless you are dealing with uploading files. We will expand more on
this later. |