Home / ASP.NET Wiki / State Management

State Management

 Rate It (12)

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.
  • Profile - Stores the data in the database. Can be used to retain user data over multiple request and session.

 

Whitepapers/Blogs

Videos

Enjoy! Be sure to explore the sub-topics.

Revision number 9, Saturday, February 27, 2010 8:55:59 AM by mbanavige

Comments

Cool main page for state management

Nice 1

nice article to mention all the state management types in one place...

Great work !!!

Great introduction on the topic!! Very informative.

nice

In This Section

Maintaining the Session Id through out the Session

Hi, Many of us come across situation like, just need a unique session id through out the session irrespective of whether the data is stored in the session or not. If you just write like, String strSessionId = Session.SessionId; It will fectch the Unique session

ASP.NET and Load balancing.

In one of our project the site usage of site was very heavy and we need to migrate it to load balancing server. I have never configured the sites in the load balancing server but it was quite interspersing experience Here are the some points which we need

How Sessions Time Out....?

I wonder some times how statemanagement efficiently helps a developer to handle the user sessions. Session state management is one which should be handled with care, Other wise it can create various problems. We have to identify how are these sessions expire

Maximum length of Querystring in ASP.NET

Maximum length of Querystring is based on the browser not depend upon the asp.net. here is some information Maximum length of a querystring in IE 4.0 and above is ~2048 characters IE. 4,5,6,7, - 2,048 characters. Opera supports - 4050 characters. Netscape

Session

ASP.NET Session state provides a place to storevalues that will persist across page requests. Valuesstored in Session are stored on the server andwill remain in memory until they are explicitly removed or until the Session expires. Storing and retrievinga

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

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)