36

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.

casperOne
  • 73,706
  • 19
  • 184
  • 253
Ronnie Overby
  • 45,287
  • 73
  • 267
  • 346
  • 3
    Also see this answers to this question: https://stackoverflow.com/questions/4520960/does-iis-express-support-debugging-classic-asp/27948911 – Keith Dec 07 '18 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? – Developer Webs May 16 '22 at 12:47

7 Answers7

52

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

StuperUser
  • 10,555
  • 13
  • 78
  • 137
waterlooalex
  • 13,642
  • 16
  • 78
  • 99
  • 3
    I don't know. But the first hit from Google looks promising: http://technet.microsoft.com/en-us/library/cc738693(WS.10).aspx – waterlooalex Jul 16 '09 at 15:01
  • 21
    Regarding Step #1 in IIS7 - IIS > ASP > Compilation > Debugging Properties > Enable Service-side Debugging – Eddie Groves Aug 30 '12 at 04:18
  • 1
    I have found a great guide for setting Visual Studio 2010 as a classic ASP debugger - right [here](http://justinchronicles.wordpress.com/tag/intellisense/) and managed to debug Classic ASP on Windows 8 + IIS8 + VS2012. :-) – itsho Jul 16 '13 at 12:54
  • 2
    Please include at least *some* info from the link in your answer. – Kenny Evitt Jul 24 '13 at 15:08
  • I use VS2005, it does not have "Attach to Process" option under Debug. Then I ended up using VS2010. – LifeiSHot Jul 19 '17 at 08:27
  • 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 05 '19 at 12:17
  • does not work for me. on windows 10 I can not install vs205 – xarzu Sep 16 '21 at 09:05
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.

LarryBud
  • 990
  • 9
  • 20
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).

Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
  • Is there to do this but send the errors to a log file? – Benjamin Goodacre Dec 09 '15 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. – Kenny Evitt Dec 09 '15 at 19:22
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.

arghtype
  • 4,376
  • 11
  • 45
  • 60
M A P
  • 29
  • 2
  • See [here](/a/27948911/1178314), 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 '19 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
Stephen R
  • 3,512
  • 1
  • 28
  • 45
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 :-)
hari
  • 41
  • 1
  • 4
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

David Meagor
  • 117
  • 2
  • 11
  • This is the best solution I have seen so far! Thanks! Took a bit to work out that "" needs adding to the firedebug.inc or every file along with the "" but once that was resolved it worked like a charm! – GazB Apr 25 '12 at 09:25
  • 4
    Maybe this will help. Try Team Remote ASP Debugger (http://www.remotedebugger.com). I've been debugging classic ASP with it for years. –  Sep 28 '12 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 '18 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. – David Meagor Feb 01 '18 at 13:33