Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this page:

Table of Contents


Heading 1

Content for heading 1


Heading 2

Content for heading 2


ViewState is the term introduced since ASP.NET v1.0 which is a placeholder to save the component's state into Page. The state will then be restored back to server side during postback. This is how every ASP.NET component should work. Developing Rich component has one main drawback that is the larger size of ViewState embedded into the rendered Page. This had caused critical issues in both performance and usability. We've seen many components are developed to have very rich features but yet skipping the ViewState management which in the end causing performance overhead where about 50K state per control need to be round-tripped during postback. Imagine if you have 10 controls which means there are 500K bandwidth resources wasted for the ViewState purpose.

Intersoft has invested tremendous effort and resources in researching and developing a new innovation where ViewState can be reduced by 80%. Here born the new ViewStateStorage feature.

Traditional Solution

Certainly there are many workaround suggested by Microsoft developers as well as community developers such as moving the entire ViewState to another storage such as Session. This can be done by overriding the LoadPageStateFromPersistenceMedium method and SavePageStateToPersistenceMedium method such as following:


Code Block
protected override object LoadPageStateFromPersistenceMedium()
return Session["PageState"];
protected override void SavePageStateToPersistenceMedium(object viewState)
Session["PageState"] = viewState;


The sample above shows the basic way to save the entire page's state to Session and load it back. However, there are two major issues with this solution:

  1. Inefficiency. You have to put these codes in all your pages if you can't stand for custom Base Page which oftenly have limitation.
  2. State architecture. The code above saves the state to Session with name "PageState", of course this is not feasible since it will conflict with other page and requests. Again, you need to spend time to reinvent on the State architecture.

One Click Solution

WebUI.NET Framework introduces ViewStateStorage property which should be exposed automatically for any components that derive from it. The ViewStateStorage feature enables developers to change the storage of the ViewState with only one-click by changing its value in Property Editor.

There are currently 3 possible storages for ViewState:

  • PageCache. This is the default value for ViewStateStorage. The ViewState will be stored temporary in Page's Cache for 1 hour (customizable in PageCacheDuration). The cache is using sliding expiration. 
  • Session. Each control's ViewState will be stored in Session. The state will remain valid until the user's session timed out. For scalability purpose, it is highly recommended to use this value and combine it with built-in ASP.NET SessionState's mode feature. The best approach is by using StateServer or SqlServer so that you can separate the main application server with the storage server in order to maintain the performance of main application server. Please refer to Microsoft's Web Architecture Best Practice for detailed information about SessionState.
  • Client. The traditional ASP.NET built-in implementation where ViewState will be embedded into the Page. This value is provided for backward compatibility with ASP.NET implementation in case developers prefer it.

You can configure the ViewStateStorage and the PageCacheDuration (for PageCache) globally by setting it in the Application-wide Configurations. Please click the link in the See Also section below for more information.

Related Topics

Content by Label
labelswebui-framework-features -viewstate-storage