June 2002
Intermediate to advanced
816 pages
28h 12m
English
Count
Integer = Session.Count
Returns an Integer containing the number of items currently in the Session collection.
Integer
An Integer variable that will receive the count property value.
The example adds two values to the Session collection, displays the count of the items in the Session collection, and then displays each item, using the Count property as a looping control value:
Sub Page_Load( )
Session("foo") = "Hello, "
Session("bar") = "World!"
Message.Text = "The Session collection contains " & _
Session.Count & " items.</br>"
Dim I as Integer
For I = 0 To Session.Count - 1
Message.Text &= CStr(Session(I)) & "</br>"
Next
End SubThe Count property is new for ASP.NET. In addition to using the Count property for looping through the Session collection, you can use the property to keep track of how many items a given Session stores at any given time. For example, you could write this information to a log for later review.
Read now
Unlock full access