- Basic Concepts
- Application State Data
- Session State Data
- Session Tracking
- State Management Examples
Application State Data
There are two basic types of state data: application and session. Application state data may be added directly to the application collection, as demonstrated previously. You can store any type of data in the application, even complex data structures such as datasets. However, it is recommended that large objects, such as datasets with lots of data, not be persisted in an Application variable due to performance issues. The application collection is an instance of the HTTPApplication state object and has many properties and methods. Some of these are outlined in the following list. You can also refer to the MSDN help section for a complete listing of all properties and methods of the HTTPApplication state object.
Here are the methods and properties available on the HttpApplicationState collection:
Add: Adds a new object to the HttpApplicationState collection.
AllKeys: Gets the access keys in the HttpApplicationState collection.
Clear: Removes all objects from an HttpApplicationState collection.
Count: Overridden. Gets/returns the number of objects in the HttpApplicationState collection.
Get: Returns an HttpApplicationState object by name or index.
GetKey: Returns an HttpApplicationState object name by index.
Item: Overloaded. Gets access to an object in an HttpApplicationState collection. This property is overloaded to allows access to an object by name or numerical index.
Lock: Locks access to an HttpApplicationState variable to facilitate access synchronization.
UnLock: Unlocks access to an HttpApplicationState variable to ease access synchronization.
NOTE
If you do not call the Unlock method, ASP.NET will unlock the application collection when the request ends, times out, or encounters an unhandled error.