views:

118

answers:

3

OK, So I have recently moved into the world of Web development after spending quite a few years coding in a pretty simple proprietary language, and one of my first jobs is to tweak an old classic ASP page for one of our clients. I'm using Visual Studio 2008 to try debug some problems I am having, but the page won't load at all. If I browse the site locally using IIS, then everything works without any trouble at all, so I am not sure what I am doing wrong.

Here's the error message I get;

Compiler Error Message: BC30451: Name 'VariableName' is not declared.

The way this is setup, is that file1.asp has an include for file2.asp

<!-- #include file=./includes/file2.asp -->

Then file2.asp has a form post for file3.asp

<FORM METHOD="POST" ACTION="/includes/file3.asp">

Inside file3.asp is where the variable is created.

So, when running this site via IIS, everything works, the variables look to be passed between files without any trouble, but when I try to debug the site using VS2008, I get the BC30451 error code.

Can anyone right my ship? I've been doing a lot of googling and reading of other websites that seem to deal with this issue, but a lot of it is going over my head. If anyone could please take the time to explain what & why this is happening, as well as providing some kind of solution, or pointing me in the direction of somewhere that may be able to help, it would be more than greatly appreciated.

Cheers,

Pat.

A: 

I've never tried to run classic ASP in VS2008. But it is not a compiled language, and I don't think you can run a debugger on it. When I did ASP, I just did a bunch of Response.Write to debug.

nportelli
+1  A: 

AS nportelli says, you can only use VS to edit the files, just like notepad, but with colors and intellisense.

  • You can not use the VS debugger
  • You can not use the internal web server (Cassini)

How to debug classic ASP?
I'm afraid that you will need to trace the errors adding some Response.write "step x. Doing y" in the middle of the code. You can add Response.end if you want to avoid a General error page

Eduardo Molteni
OK, I thought that VS2008 incorporated the ability to debug classic ASP with SP1, can anyone tell me how I can debug classic ASP?Also, as a side note, if anyone could explain the error I am getting, that would be nice, I'm just trying to understand what I am dealing with here, and find out what my options are.Thanks,Pat.
Patrick Ottery
SP1 adds only classic ASP IntelliSense. The error...still happens running the code in IIS?
Eduardo Molteni
Ahh, so it's intelisense only, fair enough.The error does not happen when I run the site via IIS.
Patrick Ottery
+3  A: 

You can debug classic ASP in Visual Studio 2008. The way to do it involves attaching the debugger to the process that is running your ASP pages. Keeping in mind that Classic ASP debugging only works with IIS; it does not work with the VS Development Web Server (Cassini). Also, make sure that you have enabled ASP debugging in IIS:

IIS Home Directory Properties


IIS Application Configuration

Once you have the configuration in IIS as noted above, here is how to attach the debugger:

  1. Open the Classic ASP files in Visual Studio
  2. Set a breakpoint anywhere you want to break in the server-side code
  3. View the page in a web browser (ensures that the host process is running)
  4. In Visual Studio: Debug Menu -> Attach to Process
  5. Locate the IIS ASP worker process (w3wp.exe on IIS6, dllhost.exe on IIS5.1)
  6. Attach to the script code for the host process (see below for example)

Attach Debugger Dialog

At this point, the breakpoint should bind and you should be able to debug the Classic ASP pages. (you may have to refresh the page in the web browser to get the code to execute again once the debugger has been attached)

Saul Dolgin
Wonderful, that looks to have done the trick. I access the site via IIS, and then debug by attaching to the IIS process, rather than debugging using Cassini. I read a bit on this online but couldn't get my head around it...thanks for the clarity in your suggestion, it's most appreciated.
Patrick Ottery
This one was tricky for me the first time around too. Welcome to StackOverflow!
Saul Dolgin