Collection Objects
A version of this page is also available for
4/8/2010
Collection objects are data structures that are similar to arrays and that store strings, numbers, objects, and other values. The collections that Windows Mobile supports provide a convenient way to read query string, form, and cookie data that are sent from the client browser and to create cookies on responses. Windows Mobile implements the Response.Form, Response.QueryString, Request.Cookies, and Response.Cookies methods as collections.
Windows Mobile ASP uses the same syntax that is used with IIS-based ASP for most of the collection objects.
Request.ServerVariables is implemented as a method, not as a collection, on Windows Mobile ASP; attempts to treat it as a collection object fail. For example, the following line is not valid on Windows Mobile ASP.
<% Request.ServerVariables("URL").Count %>
IIS allows the Response object to be accessed as a collection object. The Response object searches for the value that is specified in the QueryString, Form, Cookies, ClientCertificate, and ServerVariables methods and returns the value if it finds a match in this case. Windows Mobile has no support for this functionality. For example, the following action is valid on IIS, but not on Windows Mobile.
<% Request("URL") %>
None of the collection objects supports iteration. For example, the following VBScript operation returns an error message that states that the method is not implemented on Windows Mobile ASP.
<%
for each Item in Request.Cookies
Response.Write Item
Next
%>
Cookies cannot be subindexed on Windows Mobile. Only one value may be set per named cookie. For example, calling the following example fails on Windows Mobile.
<% Response.Cookies("Index")("Sub-index") = "Value" %>
Similarly, the Request.Cookies method does not parse out indexed arrays.
Only the following use of cookies is valid on Windows Mobile.
<% Response.Cookies("Index") = "Value %>
The Response.Cookies method supports the Path, Domain, and Expires attributes, which can be set individually for each cookie value. The Secure attribute is not supported in Windows Mobile ASP.
On IIS, it is possible to assign attributes to a response cookie before setting the value of the cookie or without setting the value at all. For instance, the following sequence is valid.
<%
Response.Cookies("Index").Path = "/"
Response.Cookies("Index") = "Value" ` set the Path attribute before the cookie value
%>
Windows Mobile requires that the value of the cookie be set before setting any of its attributes. Attempting to run the previous code on Windows Mobile ASP would return the error "The collection object specified is read-only."