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

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
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 %>
<html>
<head>
  <title>Collection Information</title>
</head>
<body>
<table>
<tr>
	<th colspan=2>Session</th>
</tr>
<%
  'In case a particular item gives us trouble
  on error resume next

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

<table>
<Tr>
	<th colspan=2>Application</th>
</tr>
<% for each item in Application.Contents  %>
   <tr>
	<td><%=item%></td>
	<TD><%=dumpItem(application(item))%></td>
   </tr>
<% 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
          next
        else
          result = item
        end if

        dumpItem = result
    end function
%>

Happy Programming!

Return to user tips...


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