State Management





5.00/5 (1 vote)
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
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
-
Nine Options for Managing Persistent User State in Your ASP.NET Application - MSDN Magazine article detailing the various means of maintaining state in ASP.NET.
-
State Management - good blogged overview of the decision-making process, advantages and disadvantages of storing state in various places.
-
State Management and ASP.NET - A good basic white paper enumerating your various options for state management.
KB: ASP.NET State Management Overview - A dry but fairly thorough KB article on session state. -
Microsoft ASP.NET 2.0 Providers: Introduction and Session State Providers - "Session state providers provide the interface between Microsoft ASP.NET's session state module and session state data sources." The MSDN documentation is a good place to start if you plan on writing your own, or if you just want to understand one of the existing providers.
-
State Management And Caching - This is a short section in MSDN that offers insight into a couple of a obscure details that might be of interest.
-
Fast, Scalable, And Secure Session State Management For Your Web Applications - An excellent article from MSDN magazine on the ASP.NET session state architecture.
-
Architectural And Performance Considerations - A very thoughtful blog post that can help you decide which session provider to use.
-
Troubleshooting Expired ASP.NET Session State and Your Options - Scott Hanselman covers the various options available to you when storing state.
- ASP.NET load balancing and ASP.NET state server (aspnet_state) - Maarten Balliauw on using out of process Session State in a reasonably fault tolerate way!
- ASP.NET Session State Partitioning using State Server Load Balancing - More from Maarten, this time partioning Session State.
Videos
- Understanding Web Application State - In this lesson, you will see how to maintain state in ASP.NET, including the various objects you can use to store information for your ASP.NET 2.0 applications.
- How Do I: Use Control State to Persist Information for a Custom Web Server Control - In this video Chris Pels will show how to store information related to a custom web server control in the control state which is independent of the ViewState information for the control.
- How Do I: Save and Load View State Information for a Custom Web Server Control - In this video Chris Pels will show how to persist and restore information in the ViewState of a custom user control.
- How Do I: Make use of Caching? - Watch a demonstration of Page Output Caching followed by an overview of the new Database Caching support for SQL Server 2000 and SQL Server 2005.
Enjoy! Be sure to explore the sub-topics.