39

I have to debug a classic asp site being served by IIS 7 (windows 2008).

How can I do this? I have only worked with ASP.NET.

2
  • 3
    Also see this answers to this question: stackoverflow.com/questions/4520960/…
    – Keith
    Dec 7, 2018 at 14:05
  • I have "Enable server-side debugging" enabled in IIS. But still when stop or exceptions are hit, I'm not prompted to debug the issue. And when I connect Visual Studio to my IIS process Debug points are not hit, the editor says no symbols are loaded. I'm using Visual Studio 2019. Thoughts? It worked up until we re-installed Windows a few weeks back. We've locked down security, maybe my domain account doesn't have sufficient permissions to debug IIS issues? May 16, 2022 at 12:47

7 Answers 7

53

From an MSDN blog post: http://blogs.msdn.com/mikhailarkhipov/archive/2005/06/24/432308.aspx

Here is how to make ASP debugging work:

  1. Enable ASP debugging on the server. (I also added DEBUG verb to the asp extension, but I am not sure if it is required).
  2. Open classic ASP in VS 2005.
  3. Set breakpoint.
  4. View page in browser or run without debugging.
  5. Debug | Attach to Process
  6. Locate IIS ASP worker process (w3wp.exe on IIS6) which exposes x86 and Script and attach as Script.

From eddiegroves comment below:

Regarding Step #1 in IIS7 - IIS > ASP > Compilation > Debugging Properties > Enable Server-side Debugging

8
  • 3
    I don't know. But the first hit from Google looks promising: technet.microsoft.com/en-us/library/cc738693(WS.10).aspx Jul 16, 2009 at 15:01
  • 21
    Regarding Step #1 in IIS7 - IIS > ASP > Compilation > Debugging Properties > Enable Service-side Debugging Aug 30, 2012 at 4:18
  • 1
    I have found a great guide for setting Visual Studio 2010 as a classic ASP debugger - right here and managed to debug Classic ASP on Windows 8 + IIS8 + VS2012. :-)
    – itsho
    Jul 16, 2013 at 12:54
  • 2
    Please include at least some info from the link in your answer. Jul 24, 2013 at 15:08
  • 1
    If you don't see the ASP icon in IIS, you may need to add the feature through "Turn Windows Features On and Off" -> Internet Information Services -> World Wide Web Services -> Application Development Features -> ASP
    – Vince I
    Apr 5, 2019 at 12:17
8

I realize this is old, but thought I'd reply to help others since I was looking something else up.

You can use Visual Studio to debug Classic ASP.

If you're running a local copy of IIS, just attach the debugger to the w3wp.exe process and you can set breakpoints, add variables to watch windows, etc.

If you have more than 1 website, it's helpful to run each in a separate application pool, and you'll be able to identify different w3wp.exe process in the Attach Process window.

Just choose "script" as the debugger type. If you're running IISExpress, then the iisexpress.exe process is the correct one to attach to.

4

I've found that a useful setting to enable is found at the server level under ASP > Compilation > Debugging Properties > Send Errors To Browser. Set that to "True".

This may not be appropriate under all circumstances (e.g. for an internet-accessible site).

2
  • Is there to do this but send the errors to a log file? Dec 9, 2015 at 16:40
  • 1
    @BenjaminGoodacre In IIS 7.5, there's a server-level setting under the ASP section named Enable Log Error Requests and the description is "Controls whether the Web server writes ASP errors to the application section of the Windows event log. ASP errors are written to the client browser and to the IIS log files by default.". So errors should already be being logged by IIS. Dec 9, 2015 at 19:22
2

Built in classic ASP debugging is pretty poor. I put together this ASP include class which works with Firebug+FirePHP. It allows you to log values (including strings, multi-dimensional arrays and even objects created with json.asp) to the firebug console and view ASP's built in collection objects which can help (particularly with Ajax where you can't output debug data without breaking the json response.) Ajax script load times and errors are automatically logged for quick viewing.

https://github.com/dmeagor/ClassicASP-FirePHP

Released under MIT open source license

4
  • This is the best solution I have seen so far! Thanks! Took a bit to work out that "<!--#include file="JSON.asp" -->" needs adding to the firedebug.inc or every file along with the "<!--#include file="firedebug.inc" -->" but once that was resolved it worked like a charm!
    – GazB
    Apr 25, 2012 at 9:25
  • 4
    Maybe this will help. Try Team Remote ASP Debugger (remotedebugger.com). I've been debugging classic ASP with it for years.
    – user1656346
    Sep 28, 2012 at 17:55
  • I would love for this to work, but I get an error as soon as I try to call "log": ` Type mismatch: 'toJson' /lib/asp/ClassicASP-FirePHP/1.2/firedebug.inc, line 72`. Does this still work at all in the post-Firebug world?Does it work in the standard FF/Chrome Console?
    – Stephen R
    Jan 31, 2018 at 17:04
  • 1
    Bit of a blast from the past this. I've corrected the firedebug.ini script to correctly include the json.asp file. If it's still comparable with firephp then it should work. Feb 1, 2018 at 13:33
2

This is the way I figured it out:

Put a stop (write stop) on the place where you want to hit the debug point. Then run the application on browser. When the execution comes to stop it will open up debug popup asking do debug with Visual studio (a VS version must be installed). Then it will ask to attach the process and you can use f10, f11 to go step over and in. You can see the data using add watch.

1
  • See here, there is another solution for setting breakpoints in recent VS. Once attached, the solution explorer will have a "Scripts Documents" node allowing to see pages loaded by the server. From them, it is possible to set breakpoints.
    – Frédéric
    Jan 18, 2019 at 15:03
2

I use the following (which I got from somewhere online) to write to a log file. I would prefer a method for writing directly to Console in Firefox or Chrome, but this works pretty well for me.

NOTE: "timestamp" is a custom function of mine. You can probably guess what it does, and probably roll your own. ;-)

function error_log( message )
    dim objFSO, objLog
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objLog = objFSO.OpenTextFile( "ASP_errors.log", 8, true)
    objLog.WriteLine "[" & timestamp & "] VBS Message: " & message
    objLog.close
    set objLog = nothing
    set objFSO = nothing
end function
2
  1. host your site on IIS server.
  2. enable remote debugger on IIS server.(follow this tutorial)
  3. import the source code into visual studio.
  4. install remote debugging tool from here
  5. In the remote debugging tool select tools-> options -> no authentication for all users.
  6. Go to visual studio and attach to process w3wp.exe.
  7. if cant see the process (w3wp.exe). Open the website link in browser and select show for all users now u will be able to see the process and attach.
  8. Dont forget to put a debugger in the application :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.