Just as you can use the Session object, you are able to use the Application object within your ASP.NET applications. The Application object is a shared container for managing state within your applications. This object enables you to store variables or object references that are available to all the visitors to the Web site for the life of the application. Unlike the Session object, the Application object can only run in-process, meaning that it can only run in the same process as ASP.NET. This means that if the ASP.NET is shut down for any reason, all Application data is lost.
Even though there are some limitations when compared to Session objects, you will find many benefits to using Application objects within your ASP.NET applications. Next, this chapter takes a quick look at how to use an Application objects within your code.
Very much like working with sessions, working with an Application object is easy. First, to create an Application instance, you just assign a value to the Application object as shown here:
Application["City"] = "Helsinki";
It is also just as easy to assign a variable the value of the Application object as shown in the following code:
string ProgramCity = Application["City"];
You probably noticed that this syntax is the same as the syntax you use with sessions. There is, however, a big difference between the two that you should always be aware of. Because the Application object is an application-wide object that is accessible ...