bobinorlando
asked on
Iterate through all values of HttpSessionState collection
How do I iterate through all values of httpsessionstate collection and display them on a page?
Thanks in advance.
I tried this without luck.
'Adapted from MSDN on Collectionbase class
Public Sub PrintIndexAndValues(ByVal SessionColl As HttpSessionState)
Dim i As Integer = 0
Dim myEnumerator As System.Collections.IEnumer ator = SessionColl.GetEnumerator( )
While myEnumerator.MoveNext()
Response.Output.Write(" [{0}]: {1}", i, myEnumerator.Current)
i += 1
End While
End Sub 'PrintIndexAndValues
which I then call from PageLoad
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Show the Session ID
lblSessionID.Text = "Your SessionID = " & Session.SessionID 'This shows
PrintIndexAndValues(Sessio n) 'This does not show
Response.Output.Write("abc d") 'This shows
End Sub
Thanks in advance.
I tried this without luck.
'Adapted from MSDN on Collectionbase class
Public Sub PrintIndexAndValues(ByVal SessionColl As HttpSessionState)
Dim i As Integer = 0
Dim myEnumerator As System.Collections.IEnumer
While myEnumerator.MoveNext()
Response.Output.Write(" [{0}]: {1}", i, myEnumerator.Current)
i += 1
End While
End Sub 'PrintIndexAndValues
which I then call from PageLoad
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Show the Session ID
lblSessionID.Text = "Your SessionID = " & Session.SessionID 'This shows
PrintIndexAndValues(Sessio
Response.Output.Write("abc
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use this...
For Each Key As String In Session.Keys
Response.Write(Key & " = " & Session(Key).ToString & "<br />")
Next
For Each Key As String In Session.Keys
Response.Write(Key & " = " & Session(Key).ToString & "<br />")
Next
Response.Write(Key & " = " & Session(Key).ToString & "<br />")
Next
Should this be Session.GetEnumerator()