Introduction
The first thing I do when I am asked to resolve an issue with a classic ASP application is to write a script to allow me to view the contents of memory.
This allows me to view an exact copy of all session variables, cookies, etc. at any stage in the application. I tend to have the application in one tab and the session info script in another, refreshing as I navigate the app.
I finally put together a reusable script and thought I would share.
The Render Function
Renders an HTML table containing the contents of the oCollection
parameter:
Function RenderTOC(sTitle, oCollection)
Tab = Chr(9)
NewLine = Chr(13)
If IsObject(oCollection) Then
If (oCollection.Count>0) Then
Response.Write(NewLine & "<table>" & NewLine)
Response.Write(Tab & "<caption>" & sTitle & _
"</caption>" & NewLine)
Response.Write(Tab & "<thead>" & NewLine)
Response.Write(Tab & Tab & "<tr><th>Name</th>_
<th>Type</th><th>Value</th></tr>" & NewLine)
Response.Write(Tab & "</thead>" & NewLine)
Response.Write(Tab & "<tbody>" & NewLine)
For Each D in oCollection
If (d<>"") And (oCollection(d)<>"") Then
Response.Write(Tab & Tab)
Response.Write("<tr>")
Response.Write("<th>" & _
Server.HTMLencode(d) & "</th>")
Response.Write("<td>" & TypeName(d) & _
"</td>")
Response.Write("<td>" & _
Server.HTMLencode(oCollection(d))_
& "</td>")
Response.Write("</tr>")
Response.Write(NewLine)
End If
Next
Response.Write(Tab & "</tbody>" & NewLine)
Response.Write("</table>" & NewLine)
End If
End If
End Function
Using the Code
Call RenderTOC("Application Variables", Application.Contents)
Call RenderTOC("Cookies", Request.Cookies)
Call RenderTOC("Server Variables", Request.ServerVariables)
Call RenderTOC("Form Collection", Request.Form)
Call RenderTOC("Querystring Collection", Request.Querystring)
Call RenderTOC("Session Variables", Session.Contents)
Be Sensible!
It is important not to upload this script to a production server and forget about it, as it exposes privileged information (database connection strings, etc.).
I have attached an ASP script so you can drop this on your server, tweak the accessible IP address and away you go!
History
- 27th February, 2009: Initial post