Debugging the Global.asa File

Debugging the Global.asa differs from debugging ASP files.

If there is an error in the Global.asa file (either a syntax error or runtime error), the server stops the procedure containing the error. If the Script Debugger is enabled for that ASP-based application, the server starts the debugger and displays an error message. If the Script Debugger is not enabled, an error message is sent to the client browser. In either case, the procedure containing the error stops. If you fix the error in the Global.asa file and request a page from the application again, the procedures in the Global.asa are executed again when the ASP-based application is restarted.

To control when the Script Debugger is called from the Global.asa file, 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.

When the application starts or when a user starts a new session, the corresponding procedure in the Global.asa file will run. The Script Debugger will start when the Stop or Debugger is executed. You can then step through the procedure normally, use the Command window to evaluate expressions and set values, and so on.

However, you cannot stop and restart the script by refreshing the Global.asa file. If you want to rerun the Application_OnStart script, you must stop the application and then restart it. If you want to rerun the Session_OnStart script, you can restart your browser, which starts a new session and reruns the Session_OnStart procedure. Alternatively, you can request a page that includes a script to call the Session objectÆs Abandon method, and then start a new session.