Compartilhar via


Collection Objects (Windows CE 5.0)

Send Feedback

Collection objects are data structures that are similar to arrays and that store strings, numbers, objects, and other values. The collections that Windows CE 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 CE implements the Response.Form, Response.QueryString, Request.Cookies, and Response.Cookies methods as collections.

Windows CE-based 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 CE–based ASP; attempts to treat it as a collection object fail. For example, the following line is not valid on Windows CE–based 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 CE has no support for this functionality. For example, the following action is valid on IIS, but not on Windows CE.

<% 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 CE–based ASP.

<%
for each Item in Request.Cookies
Response.Write Item
Next 
%>

Cookies cannot be subindexed on Windows CE. Only one value may be set per named cookie. For example, calling the following example fails on Windows CE.

<% 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 CE.

<% 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 CE-based 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 CE requires that the value of the cookie be set before setting any of its attributes. Attempting to run the previous code on Windows CE–based ASP would return the error "The collection object specified is read-only."

See Also

Server and Collection Objects

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.