Debug your classic ASP Pages in Visual Studio 2005
This was originally posted at vanslaars.com in December of 2006. I have not tried this with Visual Studio 2008 (and probably won’t have a reason to anytime soon) but I am pretty confident that it would work with 2008 as well told that it does NOT work.
I don’t do much work with classic ASP pages, but part of my role in my current position involves maintaining legacy ASP websites until they are all converted to ASP.NET 2.0. The thing that really gets to me when working with classic ASP are the generic server errors that tell you practically nothing about what went wrong… this, coupled with the fact that none of the members of the current team were here when these applications were written, makes it very difficult to track down and fix bugs.
Well, there is a solution, yet it seems to be a difficult one to find instructions on. Since the first time I worked my way through this, some additional information has been publshed on various blogs… this is my attempt to help fill the gap for those searching desperately for the steps involved in debugging ASP pages through Visual Studio 2005.
The first thing you need to keep in mind is that this requires IIS (5 or 6) and WILL NOT work through VS 2005’s built-in Cassini web server.
Secondly, before you start working through the steps, you need to run your page without debugging (just browsing to it on localhost will do too) BEFORE trying to debug… this requires you to attach the debugger to a process, therefore, the process needs to be started before you attempt to debug (this one got me a couple of time when I first attempted it).
So, here are the steps:
- Make sure your site is set to run through IIS (not Cassini)
- Make sure you enable ASP debugging on your server
- Open your target ASP file in Visual Studio 2005
- Set a breakpoint somewhere in your ASP page
- Run your page without debugging from Visual Studio (or browse to the page through localhost)
- In the Visual Studio menu, go to Debug -> Attach to Process
- Choose the process:
In IIS 6 (Server 2003) choose w3wp.exe
In IIS 5.1 (XP Pro) you want to choose dllhost.exe - Unfortunately, it isn’t this simple though… you will need to attach to the process based on the process id to ensure that you have the correct process. In order to do this: follow these steps:- Download the ListDLLs utility from sysinternals.
- Assuming you have the ListDLLs executable available on your machine, in a command prompt, go to the directory which contains ListDLLs and run the following command:
listdlls.exe -d asp.dll - This will return the process id for the instance of dllhost that loaded asp
- Use this ID to select the process in the Attach to Process dialog
- You may need to refresh your ASP page in the browser to hit your breakpoint.
I hope this helps out the next person having difficulty finding these steps.
Happy Debugging.
I have tried and failed with Visual Studio 2008, but works great with 2005. Also, editing asp files is more difficult in 2008 since it doesn’t have intellisense nor color-coding for asp files, but 2005 does just fine. I guess Microsoft is quietly drawling the line in compatibility and support.
In any matter, I hope to not be dealing with ASP in any IDE from now on.
I agree with you on that one… I wasn’t a fan of ASP even before .NET was an option. I’ll update the post to make sure I don’t lead anybody down the wrong path. Thanks.