Share via


ASP Built-In Object Events

Events are used in ASP to perform actions at the beginning or end of an application or session.

Application Events

An ASP-based application is made up of all the files in the application's root directory and any subdirectories. An application starts the first time that a user opens one of the Web pages in the application and ends when the server shuts down.

The application has two events: an Application_OnStart event and an Application_OnEnd event.

You can create functions for these events in the Global.asa file. When the application starts, the server looks in the Global.asa file and processes the Application_OnStart function. When the application ends, the server processes the Application_OnEnd function.

Session Events

The Web server automatically creates a session when a user, who did not previously have a session, opens a Web page in the application. The server destroys the session either when it times out or when the server calls the Session.Abandon method.

The session has two events: a Session_OnStart event and a Session_OnEnd event.

You can create functions for these events in the Global.asa file. When the session starts, the server looks in the Global.asa file and processes the Session_OnStart function. This script is processed before the Web page that the user requested is processed. When the session ends, the server processes the Session_OnEnd function.

Note

Session tracking is on by default. If you do not want to track sessions, you can disable sessions with the @ENABLESESSIONSTATE directive.

Transaction Events

Transaction event functions are not a part of the Global.asa file. They can be called from any ASP page.

If the @TRANSACTION directive is used in an ASP page, it can participate in a transactional application. Transactions are managed by two methods of the ObjectContext object: SetAbort and SetComplete. These methods trigger events for which two functions can be written in an ASP page: the OnTransactionAbort function and the OnTransactionCommit function.

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

See Also