Plan for debugging

As everyone knows, Active Server Pages doesn't have the best debugging
capabilities out of the box, but there are several techniques you can
implement yourself that will help you with debugging down the line.
One we've found that works well is to use a simple session variable to
keep track of whether you're in "debug mode" or not. Add the following
code to the first page of your application:

if request("debug") <> "" then
   session("debug") = "true"
end if

Then, in subsequent pages of your application, you can interrogate the
value of this session variable to determine whether you should execute
all those response.write's and similar debugging code, like this:

if session("debug") = "true" then
   response.write "Variable strUser is " & strUser
   response.write "Variable intLoop is " & intLoop
   response.write "The SQL we're executing is " & strSQL
   'And so on
else
   'Just do it!
end if

When it's time to run your application in debug mode, simply invoke the
page with the QueryString "?debug=something" in your URL, like this:

http://localhost/mycoolapp.asp?debug=on

When this QueryString value is left out, the application will run in
production mode, that is, without executing all your debug code.

You might also like...

Comments

ElementK Journals

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“To iterate is human, to recurse divine” - L. Peter Deutsch