The Contents collection is a group all of the items that have been added to the application through a script command. You can use the Contents collection to obtain a list of items that have been given application scope, or to specify a particular item to be the target of an operation.
Application.Contents(Key)
The Application.Contents collection contains those items that have been declared at the application level without using the <OBJECT> tags. This would include both objects created with Server.CreateObject as well as scalar variables established through an Application declaration. In the following script, for example, both MyVar
and MyObj
would be members of the Application.Contents collection:
<%
Application("MyVar") = "Hello"
Set Application("MyObj") = Server.CreateObject("MyComponent") %>
The Application.Contents collection supports For...Each and For...Next iteration. The following two scripts illustrate each of these methods of iterating through the Application.Contents collection.
<%
For Each Key in Application.Contents
Response.Write ("Key")
Next Key
%>
<%
For i = 1 to Application.Contents.Count
Response.Write ("Key")
Next Key
%>