State Management in ASP.NET and ASP.NET MVC
As we all know HTML is stateless language. It cannot persist state, so every web development framework provides facility to maintain state in one way or another way. There are different techniques available for state management in ASP.NET and ASP.NET MVC. Following is summary of all such techniques for maintaining state.
Client Based State Management Options
| View State | The ViewState property provides a dictionary object for retaining values between multiple requests for the same page. |
| Control State | The ControlState property allows you to persist property information that is specific to a control and cannot be turned off like the ViewState property. |
| Hidden Fields | A HiddenField control stores a single variable in its Value property and must be explicitly added to the page. |
| Cookies | A cookie is a small amount of data that is stored either in a text file on the client file system or in-memory in the client browser session. |
| Query String | A query string is information that is appended to the end of a page URL. |
| View Data(MVC) | ViewData is a dictionary of objects accessible using strings as keys. |
| View Bag(MVC) | ViewBag is a dynamic property. It does not require typecasting for complex objects. |
| Temp Data(MVC) | TempData is a dictionary of string key and object value. TempData keep the information for the time of an HTTP Request. This mean only from one page to another. |
Server Based State Management Options
| Application State | Application state is a global storage mechanism that is accessible from all pages in the Web application. |
| Session State | Session state is similar to application state, except that it is scoped to the current browser session. |
| Profile Properties | Profile Properties is similar to Session State. The profile-properties feature uses an ASP.NET profile, which is stored in a persistent format and associated with an individual user. |