
280
|
Chapter 13: The HttpApplicationState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
The example sets the values of two items in the Application collection. If these
items do not already exist in the collection, they will be added. The example then
displays the two values.
Sub Page_Load( )
Application.Clear( )
Application.Item("foo") = "foo"
Application.Item("foo2") = "foo2"
Message.Text = Application.Item("foo") & "<br/>"
Message.Text &= Application.Item(1)
End Sub
Notes
The Item property is accessed implicitly when using the syntax:
Application("foo") = "foo"
This syntax is often seen in classic ASP code. Explicitly referencing the Item prop-
erty is not required, but listing it may make your code more readable and
understandable than accessing it implicitly.
Note that an index may be used as an argument only when modifying a value, not
when creating a new item, and the index must be less than the number of items in
the Application collection, or an exception will be thrown.
Collections Reference
AllKeys
Dim StateVars(Application.Count) As String
StateVars = Application.AllKeys
Returns a string array of key names stored in the HttpApplicationState object.
Parameter
StateVars
A variable of type String array that will receive the array of key names.
Example
The example displays all keys of data stored to the Application object: ...