Name
Keys
Synopsis
KeysCollection = Session.Keys
Returns a NameObjectCollectionBase.KeysCollection containing the string keys associated with all of the values stored in the Session collection.
Parameters
-
KeysCollection
A variable of type NameObjectCollectionBase.KeysCollection that will receive the Keys property value.
Example
The example loops through the collection of Keys in the Session collection and then displays the key name and the value associated with it by using the Text property of the Message label control:
Sub Page_Load( ) Dim Key As String Message.Text = "Session Keys:" For Each Key in Session.Keys Message.Text &= "<br/>Key: " & Key Message.Text &= "<br/>Value: " & _ CStr(Session(Key)) Next End Sub
Notes
The Keys property provides one of many ways to iterate over the contents of the Session collection.
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.