When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
User Tips: Listing the Contents of the Session and Application Objects

By Stephen V.

Here's a page I wrote to show the contents of the session and application collections. It has proved pretty useful for me, and I figure if I can save someone else time writing it, then more power to me. :)

This code will show the contents of arrays in a collection, but it will not show the contents of arrays within arrays within a collection (how's that for confusing?). A more ambitious coder could easily modify it to recurse more deeply, but I hope few people are actually putting array arrays into the session/application.

dim item 'will be used to iterate through the contents %>
  <title>Collection Information</title>
	<th colspan=2>Session</th>
  'In case a particular item gives us trouble
  on error resume next

  for each item in Session.Contents  %>
	<td><%=item%></td>  <%'Show the item's name %>
	<TD><%=dumpitem(Session(item))%> <%'Show the Item's contents%>
   next 'For each%>

	<th colspan=2>Application</th>
<% for each item in Application.Contents  %>
<% next %>
   function dumpItem(item)
        'If it's an array we use this to iterate through it
        dim subItem
        dim result  'Will store the result

        'If it's an array we have to
        'grab its contents.  
        if TypeName(item) = "Variant()" then 
          for each subItem in item
             'Separate each with a space
             result = result & " " & subItem
          result = item
        end if

        dumpItem = result
    end function

Happy Programming!

Return to user tips...

ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article