Description
The AfterAppInit event is executed after the application is initialized.
Use this event to override any global ASPRunnerPro variables. See the description area in the Event editor for the list of available global variables.
Note: It is not recommended to use this event to display anything on the web page. Doing so may break your application.
Syntax
AfterAppInit()
Applies to pages
All pages.
Example
Let's say you need to troubleshoot your application by displaying an executed SQL query at the top of the page.
One way to do so is to proceed to the include/appsettings.asp file and set the dDebug variable to true. Though it might be tedious to change this variable back and forth.
By using the AfterAppInit event, you can display the debug info by adding debug=true to the URL.
AfterAppInit code:
if Request.QueryString("debug")="true" then
dDebug=true
end if
Sample URL: categories_list.asp?debug=true.
Note: the Database connection is not yet open in this event. If you need to perform any database operations, open the database connection manually.
set dbConnection = server.CreateObject("ADODB.Connection")
dbConnection.ConnectionString = strConnection
dbConnection.Open
dbConnection.Execute "insert into log (LastAcccessTime) values(now())"
dbConnection.Close : set dbConnection = Nothing
Note: in this event, you can also apply the Database API methods to interact with the database.
Recommended predefined actions and sample events:
•Display a message on the Web page
•Restrict access to ASPRunnerPro application by IP address
See also: