Classic Asp is kind of old fashioned or even a historical language for some folks but if you are a part of a team which is responsible for maintenance of a huge application, you have to live with Classic Asp and its limitations. Because Asp is a server side language so we have to enable Server side debugging from IIS.
There are different techniques used for debugging classic Asp code. Let’s take a look of them.
Writing Debug Messages
It is the most basic, easy but childish way of debugging classic Asp. You use Response object and print values of your desired variables all over the page.
Creating Macro
It won’t allow you to step into DLL files for obvious reasons, but I am sure it’s more efficient than writing debug messages to diagnose the issues.
Here is a small process of using this technique.
First of all, check if you have enabled server side debugging from IIS. If you haven’t then just do it by having a look as above screen shot displays.
Create a macro by choosing View->Other Windows->Macro Explorer.
Record a new Macro and paste the hooking code in the body of this macro.
Save the macro.
Hookup the debugger with IIS by opening a Browser and open any .asp page. This will load the iisprocess in the memory.
Run your macro, it will automatically hook with this process in memory.
Now open the asp page you want to debug.
Set a Break Point in the code (in active tags ofcourse
Browse to your page and it will automatically break at the break-point!
hooking code goes here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
Sub ClassicASPAttach() Try Dim os As System.Version = System.Environment.OSVersion.Version Dim IISProcess As String = "w3wp.exe" If os.Major = 5 And os.Minor < 2 Then IISProcess = "dllhost.exe" End If Dim processFound As Boolean = False Dim process As EnvDTE80.Process2 For Each process In DTE.Debugger.LocalProcesses 'Determine if the process could the IIS worker process Dim processName As String = process.Name.ToLowerInvariant() Dim processBaseName As String = System.IO.Path.GetFileName(processName) If Not processBaseName = IISProcess Then If Not processBaseName = "inetinfo.exe" Then Continue For End If End If 'Determine if the process contains asp.dll Dim aspLoaded As Boolean = False Dim diagProcess As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessById(process.ProcessID) Dim diagModule As System.Diagnostics.ProcessModule For Each diagModule In diagProcess.Modules Dim moduleName As String = System.IO.Path.GetFileName(diagModule.FileName).ToLowerInvariant() If moduleName = "asp.dll" Then aspLoaded = True Exit For End If Next 'If the process contains asp.dll, attach to it If aspLoaded Then process.Attach2("Script") processFound = True End If Next If Not processFound Then MsgBox("Could not find this IIS process. Hit a web page containing classic ASP script so that the process will start.") End If Catch ex As System.Exception MsgBox(ex.Message) End Try End Sub |
Cheers and Happy Coding