ASP.NET versionВ 2.0 retains much of the functionality of ASP.NET versionВ 1.1, including automatic page-state persistence using view state, and database support for session and application state. Additionally, ASP.NETВ 2.0 adds two new features: view-state chunking and control state.
Control State
Sometimes you need to store control-state data in order for a control to work properly. For example, if you have written a custom control that has different tabs that show different information, in order for that control to work as expected, somehow the control needs to know which tab is selected between round trips. The
The
Profile Properties
Many times, you need to store user-specific data in order to customize the experience of a user when they use your application. There are two major ways to accomplish this in ASP.NETВ 1.1. Session state provides an easy way to store user-specific information. However, session state is removed from memory when the user session expires. You can also use cookies to store a unique user identifier, and then persist and retrieve information from a database. However, this requires custom code. To solve this, ASP.NETВ 2.0 provides a new feature called profile properties, which allows you to store user-specific data.
The profile properties feature is similar to session state, except that the profile data is not lost when a user session expires. Instead, the profile properties feature uses an ASP.NET profile that is stored in a persistent format and associated with an individual user. The ASP.NET profile allows you to manage user information without requiring that you create and maintain your own database. In addition, the profile makes the user information available using a strongly typed API that you can access from anywhere in your application. You can store objects of any type in the profile. The ASP.NET profile feature provides a generic storage system that allows you to define and maintain almost any kind of data while still making the data available in a type-safe manner.
For more information, see ASP.NET Profile Properties Overview.
View-State Chunking
View state provides an easy way to automatically persist field and control data on the page without having to manually request it and then re-populate during round trips to the server. It also allows you to store custom data on the page in the ViewState property.
However, view-state data can, in some cases, become very large. Because view-state data is stored in hidden fields, some proxies and firewalls will prevent access to the page that contains them. For this reason, the ASP.NETВ 2.0 page framework introduces a feature called view-state chunking. If the amount of view-state data becomes too large, view-state chunking will automatically split the data into chunks and put the data into multiple hidden-form fields.
To enable view-state chunking, set the
For more information, see View State Overview.
Custom Session-State Management
By default, session-state values and information are stored in memory within the ASP.NET process. ASP.NET also provides session-state providers that allow you to use a session-state server that keeps session data in a separate process, or you can persist session state data to a SQL database. However, with ASP.NETВ 2.0, you can create custom session-state providers that allow you to customize how session-state data is stored in your ASP.NET applications. For example, you might consider creating a custom provider for the following reasons:
-
You need to store session-state information in a data source other than SQLВ Server, such as a Visual FoxPro database or an Oracle database.
-
You need to manage session-state information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. An example of this would be shopping cart data that is stored with a predefined schema in an existing a SQLВ Server database for a company or Web site.
For more information, see Implementing a Session-State Store Provider.
The HiddenField Control
View state gives you the programmatic ability to store data on a Web page and it automatically retrieves, persists, and maintains that data in hidden form fields on the page. However, ASP.NETВ 2.0 adds a new Web control, the