
420
|
Chapter 19: The HttpSessionState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
Sub Page_Load( )
If Session.Count > 0 Then
Session.RemoveAt(0)
Message.Text = "The item at index 0 was removed."
Else
Message.Text = "The item at index 0 does not exist."
End If
End Sub
Notes
The RemoveAt method allows items to be removed from the Session collection by
index rather than by key. As in the example above, the items that follow the
removed item will shift one position in the collection when the item is removed. If
you remove an item by index and call RemoveAt again with the same index, you
will remove the item that immediately followed the original removed item.
Events Reference
Start
Sub Session_OnStart( )
'Event handler logic
End Sub
Fired when the session is created. The event handler for this event should be
defined in the global.asax application file.
Parameters
None
Example
The example writes an entry to both the Application Event log and the IIS log for
the application to indicate that the Start event has fired:
<Script language="VB" runat="server">
Sub Session_OnStart( )
Dim EventLog1 As New System.Diagnostics.EventLog ("Application", _
".", "mySource")
EventLog1.WriteEntry("Session_OnStart fired!")
Context.Response.AppendToLog("Session_OnStart fired!")
End Sub
</script>
Notes
The Start event is useful for performing initialization ...