Page

7.1.5- Request Object Collection Shorthand

  by NT Community Manager.
Last Updated  by NT Community Manager.  

PublicCategorized as 07. The Request and Response Objects.

Not tagged.
<< 7.1.4- Request Object CollectionsChapter77.1.6- Properties and Methods of the Request Object >>

Request Object Collection Shorthand

One nifty shortcut when using the Request object collections is to use the whole Request object as a collection. In addition to providing collection for QueryString, Form, Cookies, etc., the Request object can also combine all of these collections together. This allows you to access a piece of information without knowing exactly where it came from. It comes in very handy when processing forms, since you are not dependent on the method (GET or POST) used to submit the form. For example:

 

Request("myListBox")

 

The information could be from a querystring, form, or cookie etc. One thing to be careful with is to understand the order in which ASP organizes the information in the Request collection. This becomes important if you have a querystring variable with the same name as a form field or cookie. ASP will search through the collections in the following order:

 

  • q
  • Form
  • Cookies
  • ClientCertificate
  • ServerVariables

So, for example if you have a querystring with the same name as a form field, the value in the Request collection will be the value from the querystring. Therefore, it is good to develop the habit of never using the same name for a cookie and a Form Field Name. Just prefacing your cookie names with a "c" will do the trick.

<< 7.1.4- Request Object CollectionsChapter77.1.6- Properties and Methods of the Request Object >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |