
286
|
Chapter 13: The HttpApplicationState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Remove
Application.Remove(ByVal name As String)
Removes an item by name from the Application collection.
Parameter
name
A String argument containing the name (key) of the item to remove.
Example
The example determines whether the item with the key “foo” exists in the Appli-
cation collection and, if it does, removes the item and displays an appropriate
message:
Sub Page_Load( )
If Not Application("foo") Is Nothing Then
Application.Remove("foo")
Message.Text = "Item 'foo' was removed."
Else
Message.Text = "Item 'foo' does not exist."
End If
End Sub
Notes
The Remove method is provided for backwards compatibility with classic ASP. In
classic ASP, this method was accessed through the Contents collection. In ASP.NET,
this method can be accessed either directly, as shown above, or through the
Contents collection.
RemoveAll
Application.RemoveAll( )
Removes all items from the Application collection.
Parameters
None.
Example
The example checks to ensure that at least one item is in the Application collec-
tion, and if it is, it clears the collection by calling the RemoveAll method.
Sub Page_Load( )
If Application.Count > 0 Then
Application.RemoveAll( )
Message.Text = "Application collection cleared."
Else
Message.Text = "Application collection is already empty." ...