简体   繁体   中英

How do you debug classic ASP?

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.

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

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.

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 (eg for an internet-accessible site).

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.

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

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

  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 :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM