Share via


Visual InterDev

Debugging a Global.asa file differs from debugging .asp files in these ways:

  • The Global.asa file cannot be a start page. To debug the Global.asa, you must request an ASP page. When the ASP page is requested, the server processes the Global.asa page.

  • Procedures in a Global.asa file are event-driven, unlike inline script in .asp files.

  • Procedures in a Global.asa file usually run only once per application or once per session:

    • The Application_OnStart procedure executes the first time that any page in an ASP-based application is accessed.

    • The Application_OnEnd procedure executes only when the application is shut down.

    • The Session_OnStart procedure executes only once per user session.

    • The Session_OnEnd procedure executes only when a user’s session times out or when a script explicitly calls the Session object’s Abandon method.

Enabling Debugging in the Global.asa File

Before you can debug script in the Global.asa file, you must enable debugging for ASP pages. 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 Microsoft® Internet Information Server (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 Scripts in the Global.asa File

To debug the Global.asa file, you set up a debugger call from script in the file, and then start an ASP application.

To call the debugger from the Global.asa file

  1. Open the Global.asa file in the editor, and then set a breakpoint in a script.

    –or–

    Include a statement that starts the debugger explicitly, such as Stop in VBScript or debugger in JavaScript. Place the statement at the beginning of the procedure, before any statements that you will want to step through.

  2. Request an ASP page from the current project in the browser. This causes the IIS to run the Global.asa file.

Debugging the Global.asa File in Response to an Error

If there is an error in a Global.asa file (either a syntax error or run-time error), the server stops the procedure containing the error. If debugging is enabled for that ASP application, the server prompts you to start the debugger and displays an error message. If debugging is not enabled for the ASP application, an error message is sent to the client browser. In either case, the procedure containing the error stops.

****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 Global.asa script in response to an error

  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 Global.asa 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 Global.asa file is loaded into the editor. If necessary, get a working copy of the page. If the project was already open, the Global.asa file 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.

Restarting the Global.asa File

You cannot stop and restart the script by refreshing a Global.asa file. To rerun Application_OnStart or Session_OnStart procedures, you must refresh the file or trigger the events again or otherwise restart the application.

To rerun all procedures in the Global.asa file

  • In the editor, change the Global.asa file, and then deploy it to the server.

    –or–

  • Stop and restart the Web server.

    This restarts the application and session, which runs the procedures in the Global.asa file again.