
RemoveAt | 419
SessionState
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Notes
The Remove method is provided for backward 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
Session.RemoveAll( )
Removes all items from the Session collection.
Parameters
None
Example
The example checks to ensure that at least one item is in the Session collection
(although if RemoveAll is called on an empty Session collection, no error will
occur), and if it is, it clears the collection by calling the RemoveAll method:
Sub Page_Load( )
If Session.Count > 0 Then
Session.RemoveAll( )
Message.Text = "Session collection cleared."
Else
Message.Text = "Session collection is already empty."
End If
End Sub
Notes
The RemoveAll method is provided for backward 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 has the same effect as calling the Clear method and like Clear, it clears
the contents of the Session collection, but does not remove Session-scoped objects
from the StaticObjects collection.
RemoveAt
Session.RemoveAt(ByVal ...