ASP.NET State Management Comparison

The following is a chart that I often use in ASP.Net classes to compare State Management options.
Where?What?Who can seeLife spanIssuesNew inNotes
User's browser or diskstringscurrent usercurrent browser session or set expire datelimited data size (typically 4096 bytes), cookie limit (typically 20 per site)user can disableancient history!  
Hidden HTML fieldsbrowserstringscurrent userone page postback (one round trip)limited to text and visible as Page Source textancient history! Easy to hack!
Applicationweb server RAM (1)objectsall sessionsuntil server is restartedlimited by RAMClassic ASP 
Sessionweb server RAM (1)objectscurrent userend of user's session (Session.Abandon or timeout [default 20 minutes])limited by RAMClassic ASP 
ViewStatehidden INPUT in pageobjectscurrent userone page postback (one round trip)bandwidth and slower page load <i>and</i> post timesASP.Net 1.0Can be disabled by the developer (per page, web.config or code)
ControlStatein ViewStateobjectscurrent userone page postback (one round trip)Not as simple to use as ViewStateASP.Net 2.0Cannot be disabled by the developer using the control
Cache (2)web server RAMobjectsall sessionsUntil:
- Expires
- a dependency changes
- RAM is needed
You must always check to see if the object still exists as cached items are both automatically deleted and are deleted when RAM runs low. ASP.Net 1.0Can be used as an Application object that can expire


(1) State can be stored in local server RAM (InProc), another server's RAM (StateServer), SQL Server (SQLServer) or a custom destination. For any option other than InProc all objects must be serializable.

(2) Cache is not usually mentioned in lists of state options, but is nearly identical to Application with the addition of expiration.

No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.