.NET Mobile Web Developer's Guide

State Management in ASP.NET

One of the most challenging aspects of Web application development is maintaining state. You can think of state as the condition of the information used in the application at any given point in time. ASP.NET has done a great job of improving state management over what is available in traditional ASP development.

Application State

Application state is maintained through the Application object and is available to all resources accessible to a given ASP.NET application. You can use Application state to help reduce the cost associated with expensive data retrieval. An example would be to retrieve data once, store it in Application state, and then retrieve it from there when needed instead of calling the database. A simple example of using Application state is as follows:

' Create and set an Application level valueApplication("ProjectName") = "MyProjectName"' Use Application level valueTextbox1.text = Application("ProjectName")

However, although it can be beneficial in reducing overhead for retrieval of information, you have to be very careful when implementing it for data manipulation purposes. Any application that can be accessed by several users at the same time and is using it for data manipulation is at risk for concurrent access issues. You can access Application state through the HTTP Application class using the Application property. To reduce the risk of concurrency issues, use the Lock() method of the HttpApplicationState class. This will prevent anyone else from updating or using the Application state at the same time. Just remember when you are done to...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Application Service Providers
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.