Share via


How to: Debug Global.asa files

Global.asa files are used by legacy ASP Web applications. In the Global.asa file, you can specify event scripts and declare objects that have session or application scope. This section contains the information on debugging Global.asa 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.

To break in the Global.asa file while debugging

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

    —or—

    Place a VBScript Stop statement or JScript debugger 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 and stop at the breakpoint, Stop statement, or debugger statement.

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

  • Modify the Global.asa file in the editor, then deploy it to the server.

    —or—

  • Stop and restart the Web server.

    Stopping and restarting the Web server restarts the application and session, which runs the procedures in the Global.asa file again.

See Also

Other Resources

Debugging ASP Applications