Debugging Server Script

See Also

From Visual InterDev you can debug server script that execute 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.

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

Before you can debug server script in ASP pages, you must enable debugging.

To 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, choose Automatically enable ASP server-side debugging on launch.

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.

To debug script on the server, debugging must be enabled for the application containing the .asp files you are working with. For more details, refer to the documentation for Microsoft Internet Information Server.

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 automatically attaches the debugger to the document running on the server. When server script execution reaches the line with the breakpoint, the debugger displays the page in the editor with that line highlighted.

  5. If the .asp file is part of your project, 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.

Tip   You can also add a Stop statement (in VBScript) or debugger statement (in JScript) to launch the debugger from within a script.

If a server script is already running, and you detect a problem, you can debug it on the spot.

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.

If debugging is enabled for an application on the server and the server encounters a syntax error or run-time error in a server script, it displays an error message in the requesting browser.

To debug server script in response to an error

  1. In response to the error, choose Yes.

    Visual InterDev is launched. The debugger attaches itself to the script with the error and displays the page in the editor.

  2. If the page is part of a project in Visual InterDev, open the project, get a working copy of the file, open it, fix any errors, save the file, and then deploy it to the server. Then in Internet Explorer, refresh the page.

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.