ASP.NET View State Caching Properties and Overview
ASP.NET View State is a mechanism that persists page, control, and custom state values across multiple HTTP requests. However, it's important to note that ASP.NET applications that utilize View State may experience performance overhead due to the handling and transmission of View State data. Thus, caching View State on web servers sends a much smaller payload to the user's browser containing only a unique ID for the particular View State. As a result, the page uses less bandwidth, which enhances performance and improves application scalability. and the ASP.NET application also scales much better. Unlike other SQL-based adapters, NCache achieves sub-millisecond speeds for access times using in-memory clustering and avoiding the database-access bottlenecks associated with SQL-based View State storage.
Following are the key advantages of using NCache ASP.NET View State:
Payload Reduction: It reduces the size of the HTTP request/response by transmitting only a token rather than sending large encoded View State data.
Distributed Access: Synchronized state across web farms prevents "Session Stickiness" requirements.
Enhanced Security: It holds critical information in the memory of the server and not in the browser.
Benefits of Caching ASP.NET View State on the Web Server
View State is an encrypted text string containing the state of web form, controls, and widgets which is sent to the user's browser to preserve the state across post-backs. For forms with a lot of controls, DataGrid control, or some other complex controls, the View State can become quite large.
Another drawback is heavy ASP.NET View State where the increased bandwidth usage increases the bandwidth cost considerably. For example, if 60-100k of additional ASP.NET View State data is appended to each HTTP request, this multiplied by the total number of transactions results in exceptional bandwidth consumption.
Moreover, there is a security risk with sending confidential data as part of ASP.NET View State. Furthermore, encrypting it before sending is also costly.
Hence, this is why it should be considered to cache the View State:
- View State is large (tens of KBs) on large forms and DataGrid.
- Large View State slows down page download time.
- Large View State slows down post-back request time.
- Cache View State on web servers & send only a token to the user.
- View State is stored in a distributed cache and remains accessible to all web servers in the farm, avoiding a single point of failure when an appropriate cache topology is used
NCache's View State Caching addresses these issues. The following are some of its features:
Payload Optimization: NCache reduces the request/response payload which improves the overall request time.
Distributed State: NCache provides distributed View State storage that is accessible to all web servers in the farm. Therefore, if a postback is routed to a different web server, the View State can still be retrieved from the cache.
Categorized Sessions: NCache allows View State to be categorized according to its respective session.
Configurable Caching Limits: For longer sessions with abundant amounts of View States, it is now possible to limit View State per session to a configurable number. Metadata is used for this purpose and is also cached. Additionally, metadata can be locked through the Web.config file.
Page level Grouping for View State: NCache allows grouping on page level, multiple pages can be coupled to define a group. For each group, different configurations can be set.
ViewState.xml: This XML file is required for page-level View State grouping. It can contain multiple web application configurations, each with one or more View State groups.
In This Section
ASP.NET View State Content Optimization Configuration
Explains how Content Optimization can be configured and used in NCache applications.
Group ASP.NET View State with Session
Explains how View State can be grouped with sessions in your application.
Limit ASP.NET View State Caching
Provides a solution to limit View State Caching per group and per session.
Page Level Grouping for ASP.NET View State
Describes how View State caching can be performed at a micro level, i.e., page level.