Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Debugging
 Debugging Global.asa Files
Visual Studio
Debugging Global.asa Files

The Global.asa file is a file in which you specify event scripts and declare objects that have session or application scope. This sections contains the following information on debugging Global.asa files:

Differences Between Debugging Global.asa Files and ASP Files

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 Abandon method of the Session object.

Enabling Debugging for an ASP File

Before you can debug script in an .asp file, such as Global.asa, you must select Enable ASP Debugging in the Project Properties dialog box. When this setting is selected, Visual Studio .NET checks that the server is configured for debugging at the start of the debugging session. This check includes:

  • Setting the Microsoft Internet Information Services 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 Studio .NET 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 must 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 text editor and set a breakpoint in a script.

    -or-

    Include a statement that starts the debugger explicitly, such as Stop in VBScript or debugger in JScript. 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 IIS to run the Global.asa file.

Debugging an ASP File in Response to an Error

If there is an error in an ASP 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.

You can launch the debugger in response to an error or debugger statement only if just-in-time debugging is enabled. For more information, see Just-In-Time Debugging.

To debug ASP script in response to an error

  1. When the Just-in-Time debugging dialog box appears, choose the Visual Studio .NET debugger.
  2. Open the project containing the ASP file you want to debug. If the project is already open in another instance of Visual Studio .NET, you cannot open it again, and Visual Studio .NET creates a new solution and project instead.

    The ASP file is loaded into the editor. If necessary, get a working copy of the page. If the project was already open, the ASP 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 Studio .NET and start the debugger there.

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.

See Also

Global.asa Reference | Debugging an ASP Web Application | ASP Remote Debugging Setup

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker