State Management in ASP.Net
* Viewstate * Session Variables * Application Variables * Cache * Cookies Now the question arises that when to use what? 1- Viewstate Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose “EnableViewstate” property is “true”. You can also explicitly add values in it, on an ASP.NET page like: Viewstate.Add( “TotalStudents”, “87″ ); Viewstate should be used when you want to save a value between different roundtrips of a single page as viewstate of a page is not accessible by another page. Because Viewstate renders with the page, it consumes bandwidth, so be careful to use it in applications to be run on low bandwidth. 2- Session Variable Session variables are usually the most commonly used. When a user visits a site, it’s sessions starts and when the user become idle or leave the site, the session ends. Session variables should be used to save and retrieve user specific information required on multiple pages. Session variables consu