October 19, 2002 - Using the Global Session and Application Objects | 2 | WebReference

October 19, 2002 - Using the Global Session and Application Objects | 2

Yehuda Shiran October 19, 2002
Using the Global Session and Application Objects
Tips: October 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

ASP.NET inherited the built-in objects from ASP. These objects are global in the sense that you don't need to construct them or pass them around; they are always there. There are five built-in objects: Request, Response, Server, Session, and Application.

The Session object is used to store information for the duration of the current user's Web-server session. Session properties may span across applications running in parallel or in sequence, as long as they are running during the same session. The Session object has a single method, Abandon(), which lets you abandon the current session and destroy any objects currently alive. The Session object also includes two properties: SessionID, and Timeout. SessionID is the identifier for the session. It is unique as long as the Web-server is up. Rebooting the system will start using the same numbers from the beginning. Timout specifies the time after which the session will be destroyed.

The Application object stores information for the duration of the application (a group of pages with a common root). Generally, since the application is up whenever the Web server is up, the Application object persists as long as the Web server is up. A common use of the Application object is to store the number of users that enter the application. The drawback for using the Application object is that objects may deteriorate with the number of users, if not recreated for every new user.