INFO: Active Server Pages' Request.Form and Request.QueryString Return Objects

ID: Q173317


The information in this article applies to:


SUMMARY

The values returned by Request.Form and Request.QueryString are actually objects, rather than strings as you would expect. This causes subtle conversion problems in server-side scripts, especially JScript.


MORE INFORMATION

The following call evaluates to TRUE:


   <% IsObject(Request.Form("Valid_Form_Value")) %> 

This is due to the fact that the Request object returns an IRequestDictionary object rather than a string. In most cases, this subtle fact goes unnoticed because the scripting engine simply substitutes the "Default Value" of the object into scripts as necessary. This is what happens when you assign the requested value to a variable, as shown in the following example:

   <% MyValue = Request.QueryString("Valid_QueryString_Value") %> 

However, there are some scenarios where this subtlety causes problems. In particular, it may be necessary to perform explicit casts in JScript or when calling automation methods on objects. Another option is to use the .item syntax to extract the default value of the object. The following IsObject call evaluates to FALSE and demonstrates use of the .item syntax.

   <% IsObject (Request.QueryString("Valid_Form_Value").item) %> 


REFERENCES

For the latest Knowledge Base artices and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:

http://support.microsoft.com/support/vinterdev/

Additional query words:


Keywords          : kbASP kbASPObj kbScript kbVisID kbVisID100 kbGrpASP 
Version           : winnt:
Platform          : winnt 
Issue type        : kbinfo 

Last Reviewed: May 27, 1999