Visual InterDev

You can debug client 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 client script in Internet Explorer, you must be using Internet Explorer 4.0. Debugging must also be enabled in Internet Explorer (this is the default).

It is also highly recommended that you do not use Active Desktop™ mode of Internet Explorer when you are debugging, or set the option in Internet Explorer to launch each new instance of the browser in a new process.

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 Client Script Debugging for ASP Pages

When Internet Information Server (IIS) processes an ASP page, the resulting page sent to the browser can be considerably different than what you see when you edit the ASP page in the editor. Server script can generate new client content dynamically, or conversely, a large quantity of server script can result in only a few lines of client HTML output. This situation introduces problems when you set breakpoints in client script inside an ASP page because the line on which you set the breakpoint can move dramatically within the file by the time the page reaches the browser.

The solution is to enable client-side debugging in ASP pages. Doing so specifies that IIS tracks the location of client script breakpoints in an ASP page, and passes the location of those breakpoints to Internet Explorer, so that Internet Explorer can stop at the correct locations.

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.

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.

****Note   ****If you intend to work exclusively with client script in .htm files, you do not need to enable server debugging or perform the following procedure.

To automatically enable client 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 that the Automatically enable ASP server-side script debugging on launch option is checked

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

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.

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

Debugging Client Script Within a Solution

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

To debug a script from within a solution

  1. In Visual InterDev, open the project containing the page you want to debug and load the page into the editor.

  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 script to debug. For details, see Setting Breakpoints.

  4. From the Debug menu, choose Start.

  5. If debugging for client script in ASP pages has not been enabled as described above, Visual InterDev displays a message prompting you to enable debugging for ASP pages. Your options are:

    • Choose Yes if you are working with an ASP page and want Visual InterDev to automatically enable debugging.

    • Choose No if you if you are working with an HTM page and will not be navigating to an ASP page during your debugger session.

  6. If client debugging in ASP pages is enabled, and if this is the first time you have launched a debugging session since opening the project, you are prompted to provide user information that identifies the debugging process on the server. (You are prompted even if you are currently working with an .htm file, in case you navigate to an ASP page.) Enter your domain and name in the form domain\name and your password.

    ****Note   ****You might experience a delay the first time you launch a debugging session for the current project while Visual InterDev establishes the proper debugging configuration on the server.

    Visual InterDev launches Internet Explorer and loads the page into it. When Internet Explorer reaches the breakpoint, it stops and displays the source code in the editor window. If the breakpoint is in an event handler script, you must trigger the event to reach the breakpoint.

  7. If you find an error, fix it, and then save the file. 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.

  8. From the Debug menu, choose Restart.

Debugging Client Script in a Running Document

If a client script is already running in Internet Explorer and you detect a problem, you can stop the script and debug it on the spot. You can debug a running document from within Visual InterDev or from within Internet Explorer.

****Note   ****If you are working with an ASP page, debugging must be enabled on the server. For details, 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.

You can attach to a document directly in Visual InterDev.

To debug a running document in Visual InterDev

  • In Visual InterDev, choose Processes from the Debug menu. In the Processes dialog box, choose Microsoft Internet Explorer, choose Attach, and then choose the script you want to debug.

    –or–

  • If you have already attached to a running document, in Visual InterDev, choose Break from the Debug menu. The debugger will stop at the next script statement that is executed.

If Visual InterDev is not already running, you can launch the debugger from Internet Explorer.

To debug a running document from Internet Explorer

  1. In Internet Explorer, choose Script Debugger from the View menu, and then choose Break at Next Statement. In the browser, trigger the event that calls the script you want to debug.

    –or–

    In Internet Explorer, choose Script Debugger from the View menu, and then choose Open.

  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, so Visual InterDev creates a new solution and project instead.

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

If you make changes to the file, save it and re-deploy it to the server. Refresh the file in Internet Explorer before running the script again.

Debugging Client Script in Response to an Error or Debugger Statement

If Internet Explorer encounters a syntax or run-time error, 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 Visual Basic®, Scripting Edition (VBScript) or a debugger statement in JScript™, to launch the debugger from within a script.

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 in response to an error or debugger statement

  1. When Internet Explorer encounters an error or a statement that starts the debugger, it displays an error message prompting you to debug. Choose Yes.

  2. A new instance of Visual InterDev is launched. 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, so Visual InterDev creates a new project instead.

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

    Note   If you are debugging a client script generated by an .asp file, the line numbers reported in error messages refer to lines in the HTML document currently displayed in the browser. These usually do not correspond to line numbers in the original .asp file, because server script does not appear in the HTML output of an .asp file. For more information, see Debugging Mixed Client and Server Script.

If you make changes to the file, save it and re-deploy it to the server. Refresh the file in Internet Explorer before running the script again.