O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.11. Managing State: The Application Object

There is analogous support for maintaining values across sessions within the Application object. The Global class provides a skeletal definition of an Application_Start() event handler. It is invoked once at the start of the application. This is where we initialize global data for our application. For example, let's provide values to hold total mouse clicks across all sessions:

protected void
Application_Start(Object sender, EventArgs e)
{
      Application.Add( "TotalAnnaCount", 0 );
      Application.Add( "TotalPoohCount", 0 );
      Application.Add( "TotalMissCount", 0 );
}

These values can be accessed concurrently through multiple sessions, so we need to be more careful when writing them. For example, the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required