Visual InterDev

Visual Studio 6.0

Debugging Server Script

From Microsoft® Visual InterDev™ you can debug server script that executes on Microsoft® Internet Information Server (IIS). If IIS is running on your computer, you can debug server script in much the same way that you debug client script. If the server is on another computer, you can use remote debugging from your computer to find errors in the server script. For details, see Debugging Remotely.

You can debug server script in any of these ways:

  • Run a page containing the script to debug from within your Microsoft Visual InterDev solution.

  • Attach the Visual InterDev debugger to a process (page) already running in Microsoft® Internet Explorer.

  • Respond to a syntax or run-time error in a script, called just-in-time debugging.

  • Include a statement in script that starts the debugger.

Note   To debug script in ASP pages, you must be running version 4.0 or later of Microsoft Internet Information Server (IIS).

Note   If you are writing ASP pages that use the scripting object model, you can set options that help you find errors and trace events. For details, see Debugging Script Objects in ASP Pages.

If a Web page contains a mixture of client and server script, you can use the Visual InterDev debugger to debug both. For details, see Debugging Mixed Client and Server Script.

Enabling Server Script Debugging for ASP Pages

Before you can debug client script in ASP pages, you must enable debugging. You can manually enable debugging for your ASP application as described under "Enabling ASP Debugging on the Server" in the Troubleshooting topic. Alternatively, Visual InterDev can automatically enable debugging on the server as needed.

To automatically enable script debugging in ASP pages

  1. In the Project Explorer, right-click the project and choose Properties to display the Property Pages dialog box.

  2. Choose the Launch tab.

  3. Under Server script, make sure Automatically enable ASP server-side debugging on launch is checked.

When this option is set, each time you start a debugging session Visual InterDev checks that the server is configured for debugging. This includes:

  • Setting the IIS application to run in its own memory space (in COM terms, it runs "out of process").

  • Enabling the IIS application's debugging options.

  • Setting up a Microsoft® Transaction Server (MTS) package to allow you to attach the debugger to the Web application. The package's identify is set when you first start the debugging session by asking you to provide your name and password.

    Note   You can perform the first two steps manually on the server. For details, see "Enabling ASP Debugging on the Server" in the Troubleshooting topic.

When you quit your debugging session, Visual InterDev restores the server debugging settings and out-of-process setting to their previous values.

Debugging Server Script Within a Solution

If you are working in a Visual InterDev solution, you can debug server script by launching the debugger.

Note   Before debugging server script, make sure debugging is enabled as described above or under "Enabling ASP Debugging on the Server" in the Troubleshooting topic.

To debug server script from within a solution

  1. In Visual InterDev, open the project containing the server script you want to debug.

  2. Make the page your project's start page. In the Project Explorer, right-click the page and choose Set as Start Page.

  3. Set a breakpoint in the server script you want to debug.

  4. From the Debug menu, choose Start to launch the project.

    Visual InterDev attempts to attach the debugger to the document running on the server.

  5. If this is the first time you have started the debugger since opening the current project, you are prompted to provide user information used to identify the debugging process on the server. Enter your domain and name (in the form domain\name) and password.

  6. The browser opens, and you can proceed with debugging. When server script execution reaches the line with the breakpoint, the debugger displays the page in the editor with that line highlighted.

  7. Fix any errors, save the file, and then from the Debug menu choose Restart. If you do not have a working copy of the file, right-click the name of the file in the Project Explorer and choose Get Latest Version before you make modifications.

Debugging Server Script in a Running Document

If debugging has been enabled on the server for your project and you detect an error while the application is running, you can attach the debugger to it. For details about enabling debugging on the server, see "Enabling ASP Debugging on the Server" in the Troubleshooting topic.

You can attach to a running document only if attaching is enabled.

To enable just-in-time debugging

  1. From the Tools menu, choose Options.

  2. In the Options dialog box, choose Debugger.

  3. Under Script, check Attach to programs running on this machine.

To debug a running script

  1. In Visual InterDev, choose Processes from the Debug menu. In the Processes dialog box, choose Active Server Pages, and choose Attach.

  2. In the Running Documents window, select the script you want to debug.

  3. Set breakpoints, and then choose Restart from the Debug menu, or refresh the document in the browser.

Debugging Server Script in Response to an Error or Debugger Statement

If debugging is enabled for an IIS application on the server and the server encounters a syntax error or run-time error in a server script, you can use just-in-time debugging to find and fix it. You can also include a statement in your script, such as a Stop statement in VBScript or a debugger statement in JScript, to launch the debugger from within a script. For details about enabling debugging on the server, see "Enabling ASP Debugging on the Server" in the Troubleshooting topic.

Note   If a debugger is installed on the server computer, the server does not pass error information through to the client. Instead, it displays an error message on the server computer's monitor. For more information, see "Just-in-Time Debugging of Server Pages" in the Troubleshooting topic.

You can launch the debugger in response to an error or debugger statement only if just-in-time debugging is enabled.

To enable just-in-time debugging

  1. From the Tools menu, choose Options.

  2. In the Options dialog box, choose Debugger.

  3. Under Script, check Just-In-Time debugging.

To debug server script in response to an error or debugger statement

  1. When an error message appears prompting you to start the debugger, choose Yes.

  2. A new instance of Visual InterDev is launched and you are prompted to open a project. If Visual InterDev is already running, a second instance is launched.

  3. Open the project containing the file to debug. If the project is already open in another instance of Visual InterDev, you cannot open it again, and Visual InterDev creates a new solution and project instead.

    The page to debug is loaded into the editor. If necessary, get a working copy of the page. If the project is already open, the page is loaded as read-only file in the new project.

If server debugging is not enabled for the application, errors are displayed in the browser as text in the page. In that case, open the project containing the page in Visual InterDev and start the debugger there, as described above.

 
Show: