Share via


Collection Objects (Compact 2013)

3/26/2014

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

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

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

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

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

<% 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 Embedded Compact.

<% 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 Embedded Compact-based ASP.

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

See Also

Concepts

Server and Collection Objects