====== Dump the Session Variable ======
' Dump the session variable
Dim file As New System.IO.StreamWriter("c:\temp\Session Dump.txt", True)
Try
Dim i As Integer
Dim key, type As String
file.WriteLine("****************** " + Now().ToShortDateString() + " " + Now().ToShortTimeString() + " ******************")
For i = 0 To Session.Keys.Count - 1
key = Session.Keys.Item(i)
If Session.Item(i) Is Nothing Then
type = "(Null)"
Else
type = Session.Item(i).GetType().ToString()
End If
If type.StartsWith("System.String") Or type.StartsWith("System.Int") Or type.StartsWith("System.Boolean") Then
file.WriteLine("Session(""" + key + """) as " + type + " : " + CType(Session.Item(i), String))
Else
file.WriteLine("Session(""" + key + """) as " + type)
End If
Next
Finally
file.Close()
End Try
Or try this:
' Dump the session variable
Debug.WriteLine("****************** " + Now().ToShortDateString() + " " + Now().ToShortTimeString() + " ******************")
Debug.Indent()
For i = 0 To Session.Keys.Count - 1
key = Session.Keys.Item(i)
If Session.Item(i) Is Nothing Then
type = "(Null)"
Else
type = Session.Item(i).GetType().ToString()
End If
If type.StartsWith("System.String") Or type.StartsWith("System.Int") Or type.StartsWith("System.Boolean") Then
Debug.WriteLine("Session(""" + key + """) as " + type + " : " + CType(Session.Item(i), String))
Else
Debug.WriteLine("Session(""" + key + """) as " + type)
End If
Next
Debug.Unindent()
Debug.Flush()
{{tag>code_snippet vb session_variable}}