I missed the last bit of the initial focus Developing Web Form Pages. Primarily covering the state management, so to not leave the topic untouched I present the following notes. Cheers!
Manage State
- Control.ViewState Property – Gets a dictionary of state information that can be used to store and retrieve the view state of a server control across multiple requests for the same page. For more information read ASP.NET State Management Overview.
- The core functionality of viewstate is to read values and save values.
- PageStatePersistor.ControlState Property – Gets or sets and object that represents the data that controls contained by the current Page object use to persist across HTTP requests to the web server. Control state is an object comprised of critical view state that the controls need to function. It is contained in a separate object form normal view state information. This view state is not affected when the page view state settings are changed.
- HiddenField Class – Represents a hidden field used to store a non-displayed value.
- Another common way to manage state is with cookies. This is a non-Microsoft specific way of managing state, which is used by all browsers, web technology stacks, etc. HttpResponse.Cookies Property – Gets the response cookie collection. ASP.NET includes to intrinsic cookie collections. The collection accessed through the Cookies Collection of HttpRequest which contains cookies transmitted by the client to the server in the cookie header. The collection accessed through the cookies collection of HttpResponse contains new cookies created on the server and transmitted to the client in the Set-Cookie Header. After you add a cookie by using the HttpResponse.Cookies collection, the cookie is immediately available in the HttpRequest.Cookies collection, even if the response has not been sent to the client. For usage review How to: Delete a Cookie and How to: Write a Cookie.
- HttpRequest.QueryString Property – Gets the collection of HTTP query string variables.
- ASP.NET Application State Overview – Application state is a data repository available to all classes in an ASP.NET application. Application state is stored in memory on the server and is faster than storing and retrieving information in a database. Unlike session state, which is specific to a single user session, application state applies to all users and sessions. Therefore, application state is a useful place to store small amounts of often-used data that does not change from one user to another.
- HttpApplicationState Class – Enables sharing of global information across multiple sessions and requests within an ASP.NET application.
- Also be sure to check out the Session State Modes:
- In-process Mode
- State Server Mode
- SQL Server Mode
- Custom Mode