Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Sessions: Global.asa and Scalability
     [next Lesson]  Global.asa, Sessions, Custom Stats Resources

Global.asa Events by Charles Carroll

This page demonstrates what a blank global.asa should look like:

   filename=/learn/test/global.asa

<Test Script Below>


<script language=vbscript runat=server>
SUB Application_OnStart
END SUB

SUB Application_OnEnd
END SUB

SUB Session_OnStart
END SUB

SUB Session_OnEnd
END SUB
</script>

A global.asa code is divided into four events, or segments:

  • session_onstart
    if 100 users hit your website for example, 100 session starts are initiated and the code in this event is fired for each user before their first page is fetched and displayed. But those same 100 users can wander all over your site and another session start will not occur as long as they are actively fetching pages

  • session_onend
    Any user that does not fetch any page from your site for 20 minutes (can be adjusted in the Registry/IIS3 or the metabase/IIS4) has ended their session. The code you put in this event can not affect the users as they have already left your site but it can allow you to place cleanup code or code that dumps for, example, session data into a database.

  • application_onstart
    The webserver starts. dozens to hundreds to thousands of users hit the site. The minute the first user fetches the first file in an application directory an application_onstart occurs  and never occurs again no matter how many people are visiting. But if a webserver stops and starts and application_onstart fires. But code inside an application_onstart is code that assumes the entire casino is a "blank slate" not a busy place. If for example, application_onstarts fire often this is not a desired behavior since it may have the role of bootsrapping an app and setting certain conditions that don't make sense to set while activity is occuring.

  • application_onend
    The web server stops, the application ends.

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.