QuadComm e-commerce solutions
Home

ASP Tip: Output debug information

Q-Shop

The complete shopping cart solution

Whoever has ever programmed a complex ASP page or application has faced the problem of not being able to debug the results easily. But there is a way you can easily output all the main variables that will allow you to see why we are not getting the desired results when there is no no syntax error.

A way to do it is including a file that displays the following information:

  • Session variables
  • Application variables
  • Request Form
  • Request QueryString
  • others...

Include file (debug.asp):

<% Dim IsDebug
IsDebug = True 'Enable

If IsDebug = True Then %>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>

<hr size=1 noshadow>
<b>Debug data:</b>
<TABLE><TR BGCOLOR="#C0C0C0"><TD WIDTH="60%">
<B>Session:</B></TD><TD><B>Application:
</B></TD></TR><TR><TD>
<%
For each field in Session.Contents
Response.Write ("<B>" & field & "</B>: " _
& Session.Contents(field) & "<BR>")
Next
%>
</TD><TD valign=top>
<%
For each field in Application.Contents
Response.Write ("<B>" & field & "</B>: " _
& Application.Contents(field) & "<BR>")
Next
%>
</TD></TR>
</TABLE>
<TABLE width=100%><TR BGCOLOR="#C0C0C0"><TD colspan=2><B>
GET/POST Data:</B></TD></TR>
</TABLE>
<TABLE>
<TR><TD>
<B>Action: </B><BR>
<B>CMD: </B><BR>
<B>QueryString: </B><BR>
<B>Form: </B>
</TD><TD>
<%= Request.Form ("Action") %><br>
<%= Request.QueryString ("cmd") %><br>
<%= Request.QueryString %><br>
<%= Request.Form %>
</TD></TR></TABLE>

<% End If %>

Download the text file here.

Now we only need to add the following wherever we want to get all the data:

<!--#include file="debug.asp"-->

And that's all. I am sure you will find it as useful as I did.

Author: Carlos Baez

You can also submit your own code examples. Just e-mail them.

Read the disclaimer.

Boost your sales with Web Marketing Today Premium Edition