Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
View state is the page-level state management technique used in the ASP.NET page framework to retain the value of controls and page between round trips. Data objects such as hash tables, strings, array objects, array list objects, Boolean values and custom-type converters can be stored in view state. View state is ideally used when the data to be preserved is relatively small and the data need not be secured.
With the page load, view state is contained in a structure, so is easily available. The values contained in view state cannot be transmitted between pages. By default, the view state is switched on and regardless of whether used during a postback, it serializes the information in every control found on the page. To disable the view state for a single control, the EnableViewState property needs to be set as false. The attribute EnableViewStateMac is provided to detect any corruption attempt or technique on the view state. The mean features of view state are to store the values of control properties and pages found in the concerned page, without the help of a session, preserve the value of the control after the postback operation and to create a custom view state provider for storing view state information in a database.
View state is easy to implement and does not require any server resources. It also has enhanced security features and can be compressed or encoded and can contribute to Unicode implementation.
However there are a few disadvantages with view state. For large amounts of data, the performance is not optimal, as large values could potentially cause view state to be slow. View state can only store values for same page only. It also has security risks and requires extra coding to provide security to the information.