Thursday, August 28, 2014

ASP - Cheap Debug Input Dumper

I call it: Dave's Dastardly Diabolical Debugging Dumbass Dumper, or just Debug Dump for short.  It simply prints out any form inputs and querystring inputs and then stops the page rendering process dead.  That allows you to structure a processing page to capture inputs and then dump them before proceeding to process them; allowing you a chance to see what may be going in the wrong direction before you go further into the debug abyss.

[asp]
<%
Sub Show_InputParams ()
   Dim fn, qv, fc, qc
    fc = 0
    qc = 0
    Response.Write "

Form Inputs

"

    For each fn in Request.Form()
        Response.Write "" & fn & " = " & Request.Form(fn) & "
"

        fc = fc + 1
    Next
    Response.Write "

QueryString Inputs

"

    For each qv in Request.QueryString()
        Response.Write "" & qv & " = " & Request.QueryString(qv) & "
"

        qc = qc + 1
    Next
    Response.Write "

(processing halted)

"

    Response.End
End Sub
%>
[asp]

To try this out the quickest way, paste that mess above into a new file and save it as "dumbass.asp".  Then access it via your browser along with some test parameters (querystring inputs for now).  something like "/mysite/dumbass.asp?test1=123&a=def&x=4321"

It should print out something like the following...

Form Inputs
(no form inputs found)

QueryString Inputs

test1 = 123
a = def
x = 4321
3 querystring inputs found

(processing halted)


No comments:

Post a Comment