State Management

 Rate It (5)

ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it's difficult to decide where you should put things and how to make that decision.

You choices for state management include:

  • Application - Stored on the server and shared for all users. Does not expire.  Deprecated by Cache (below).
  • Cache - Stored on the server and shared for all users. Can expire.
  • Session - Stored on the server.  Unique for each user.  Can expire.
  • ViewState - Stored in a hidden page input (by default).  Does not expire.
  • Cookies - Stored at the client. Can expire.
  • QueryString - Passed in the URL.  Must be maintained with each request.
  • Context.Items - Only lasts for one request's lifetime.  More.

 

Whitepapers/Blogs

Videos

Enjoy! Be sure to explore the sub-topics.

Revision number 5, Monday, February 04, 2008 8:00:00 AM by aspsmith

Comments

In This Section

Session

The Session Object is one of the easiest to use and most useful aspects of ASP.NET. There are some caveats to its use when building very large systems and Web Farms, so it pays to be educated. How To Basics of ASP.NET Session State- Start here with this excellent

ViewState

ViewStateis the mechanism that allows state values to be preserved across page postbacks. Because of the stateless nature of web pages, regular page membervariables will not maintain their values across postbacks. When we need a page variable to maintain its

Application and Cache

The Cache and Application objects provide broader scope than the Session object and the data is available to all the classes within theASP.NET application. The Basics ASP.NET Application State Overview ASP.NET Caching Overview How to: Save Values in Application

Cookies

Cookies are small amounts of text that can be stored on the client pc by the browser. The cookie can be accessed both at the client through the use of Javascript and also at the server. While cookies can be a convenient way to store small bits of state information

Featured ASP.NET Web Hosting

Powerful, Award Winning ASP.NET Hosting Trusted By Over 30,000 ASP.NET Developers

3 Months Free & No Setup Fees – CLICK HERE!

Table of Contents

Top Wiki Contributors

Advertise Here