How to debug classic ASP pages in VS 2005


Quite a few people were unable to make VS 2005 to hit breakpoints in the server script in classic ASP pages. Little surprise here since the way we do ASP debugging changed since VS 2003 and there little or no information currently in VS 2005 Beta 2 docs on the topic (I filed a bug on this). Most importantly, setting BP and hitting F5 won’t work – breakpoint never binds. Two key items here:

1. Classic ASP debugging only works with IIS. It does not work with the VS Development Web Server (Cassini). 
2. In VS 2005 you have to attach to the ASP worker process (w3wp.exe in IIS 6).

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.

At this point breakpoint should bind and you should be able to hit it. You may have to refresh the page in the browser to get the code executed again. I tried on Windows 2003 SP1 Standard Server running IIS 6 and it worked for me. I want to try on XP Pro + IIS 5 next. 


Comments (30)

  1. Hi, Mikhail

    It is somewhat not related to the topic, but I have some questions regarding VS2005 and the new asp.net 2.0 model. (I’m in the middle of conversion of the big project from 1.1 to 2.0)

    1) server controls inside user controls (for example dropdownlist). Because of the new model I can not declare it in the code behind, they are already declared as protected from aspx code.

    In asp.net 2.0 I had some of these controls declared as public in order to have access from the outside. Now they are all protected, so it gives compilation errors. Is there any elegant way to solve this ?

  2. The simples way is to declare a public property that returns the inner control instance. However, when I am thinking that I need to declare an accessor method or property, I always stop and think if the code is structured right. Accessor methods that give access to otherwise private or protected members are often just hacks. Certain code restructuring may eliminate necessity to access protected members. Of course, it is not always possible.

  3. Arthur Taylor says:

    What about steps

    5)Debug | Attach to Process and

    6)Locate IIS ASP worker process (w3wp.exe on IIS6) which exposes x86 and Script and attach as Script

    Can you describe the details to carry out these actions?

    Thanks

  4. Mikhail Arkhipov (MSFT) says:

    You access Attach to Process command in the Debug menu. It display a window with all processes running in OS that you can attach to. One of the processes will be w3wp and type of code will be x86 and Script. Select the process and at the top of the dialog choose Script instead of Automatic. Click Attach.

  5. Dianne Siebold says:

    I’m trying to debug classic ASP in VS 2005 and have tried everything to get it to work. I open the web site as a web project. Then when I do Debug.StartWithoutDebugging it runs the web site from //localhost and everything looks good. But I cannot attach to the ASP.NET worker process because it’s not running. No matter what I try, the worker process doesn’t run which seems to make sense because the pages are ASP not ASP.NET. Any ideas on why this is happening or what I can try? Thanks.

  6. Mikhail Arkhipov (MSFT) says:

    You need to attach to ASP worker process, not ASP.NET process.

  7. Andy Norman says:

    If this is true, then how on earth can you now debug code in the application startup event in classic ASP ?

    You can’t attach to the w3wp.exe process when you application startup code it running so you have run it from a project in VS.NET 2003. Are you saying there is therefore now not a way to debug the startup event ?

  8. FYI –

    When running on XP Pro/IIS 5, you need to attach to dllhost.exe instead of w3wp.exe. You may have more than one instance of dllhost running on your machine, so look for the one with Type "Script, x86" and the User Name column indicates your IIS process account (IWAM_machinename).

  9. Arun says:

    I have a clarification. I used to debug ASP application in VS 2003. I shut down the system and the next day, when I tried to Debug Process, it gave me an error.

    —————————

    Microsoft Development Environment

    —————————

    Processes cannot be displayed. Access is denied. Verify that you are an administrator or a member of the ‘Debugger Users’ group on the machine you are trying to debug. After being added to the ‘Debugger Users’ group, you must log off and log back on for the setting to apply.

    —————————

    OK

    —————————

    Can you help me on this? My account is administrator account and is added in "Debugging users" group.

    Thanks.

    Arun

  10. Ron Pinkas says:

    Hi Mikhail,

    I can attach to the worker process (dllhost Script x86) but it clearly is not fully attached, as break point are never activated, and even the OutputDebugString() output is NOT being captured.

    When I do the same with VS 2003, i.e attaching to the SAME dllhost process, it DOES capture the OutputDebugString output, and break points DO activate, but my symbolic info does NOT load (compiled with VS 2005).

    FWIW, I can see 2 dllhost process, and I did try attaching to EACH seperatly as well as BOTH.

    Finally, the script engine I try to debug is compiled with VS 2005 using full debug info, and oherwise functions perfectly.

    What am I missing?

    Ron

  11. Ron Pinkas says:

    Oops, sorry in VS 2003, with the project compiled with VS 2005, the break points do NOT activate, because teh symbolic info is not loaded, but the DEbugger DOES capture OutputDebugString(), and it DOES capture exceptions. It also DID activate break point when the project was compiled with VS 2003.

    I also found I CAN tell my project to use "Web Service Debugger" and when I use url such as http://LocalHost/test.asp it DOES start IE, and it does capture an Error info posted by means of IActiveScriptSite::OnScriptError(), but break point which should have trigger BEFORE that point are NOT intercepted.

    TIA,

    Ron

  12. Ron Pinkas says:

    Solution found.

    As simple as it may sound, all I had to do was to select "Native code", in the "Attach to:" combo box, of the "Attach to Process" Dialog – the default "Automatic" simply fails to attach.

    Ron

  13. Igor Jecmenic says:

    Hi Mikhail,

    I have a question about ASP debugging. Have class library written in VB6 that is call from classic asp page. Can I debugg it all together with VS 2005 and VS 6 as I can debbug it with VS 2003 and VS 6.

    I try debugging asp page with VS 2005 and it works but in that page I have calls of methods from some extern class written in VB6, that I need to debugg it also. I can not join this 2 debuggings.

    Regards,

    Igor  

  14. Hi Mikhail,

    Thanks a lot for your posts.  They have really helped me a lot already.

    I have been trying to get Classic ASP debugging working with VS2005, in a mixed project of both .aspx and .asp files.  The only difference is that I am using XP Pro with IIS 5.1

    I followed your steps for enabling debugging.  Instead of attaching to w3wp.exe, I am attaching to the inetinfo.exe process.  

    I can start without debugging, and then if I position my cursor inside the script or <% tags.  I am able to set a breakpoint.  

    By then refreshing the .asp page using Ctrl-F5, my breakpoint is not hit, and the comment inside the Visual Studio IDE when I hover over the breakpoint symbol in the margin says:  ‘The breakpoint will not currently be hit, no symbols have been loaded for this document’

    As a result, I was almost, but not quite able to show that debugging classic ASP pages is possible in IIS5.1 on XP

    I am not able to spend any more time on this, so perhaps someone else can pick this up?

    Best wishes

    Graham.

  15. Some time ago I blogged about how to debug classic ASP applications in VS 2005 with IIS 6. A few people…

  16. stoki says:

    great

  17. I blogged earlier how to debug classic ASP with VS 2005 on IIS5 and on IIS6. However, attaching to a…

  18. Michael Monteiro says:

    Anyone know if you can debug classic ASP with Visual Web Developer Express? The Debug window does not have an option to attach to a process.

  19. No, I don’t think it is possible. VWD Express does not support attaching to processes.

  20. roy ashbrook says:

    Dave got a request to allow someone to setup Visual Studio 6 so they could use Visual InterDev. I&#8217;m

  21. Visual Studio 2005 で classic ASP をデバッグする方法

  22. Alex Gordon says:

    Setting Debugging for Interdev ASP project in Windows 2003 Server / IIS6

    // this step may not be needed.

    Open Component Services->Component Services->Computers->MyComputer->DCom Config->Machine Debug Manager->Properties->Security.

    For Launch and Activate and Access Permissions select Customize. Add  Interactive and IWAM_COMPNAME.

    In IIS6, create under your WebSites/Default Web Site your Application ABCApp, point to the folder where Interdev application and follow normal steps to create InterDev application(I did it in Master mode)

    Set in IIS ABCApp/Properties/Configuration/Debugging. Set Debugging Flags for Enable ASP server-side and client-side debugging.

    Go in IIS to Application Pools/DefaultAppPool->Properties->Identity. Set it to Configurable: IWAM_COMPNAME.

    This let me stop at breakpoints in InterDev.

  23. z_true says:

    好久没更新过了。翻找了下,这两篇博客指导了如何做1、2,记录下。要用到的工具ListDlls简单地说1.VS自带的Cassini不支持ASPdebug,必须用IIS,而且2.要用vs2005A…