Chunking Viewstate

One interresting feature a developer should know is the ability to chunk the viewstate field into multiple fields. Why you

need such feature? Some proxy servers and firewalls won't allow a request to be processed if a hidden fields' length is

large. To overcome this, You can set up in the web.config file for all the pages to have a maximum viewstate field.

<pages maxPageStateFieldLength = "1024" />

The value of maxPageStateFieldLength is in Bytes.

In this way, if the hidden viewstate field is larger than 1 kb, ASP.NET will create multiple hidden viewstate field to hold

the data entered by the user before the postback. For example if the size of the data entered by the user is 2KB, the below

fields in the page once being rendered to HTML will be created

<input type="hidden" name="__VIEWSTATEFIELDCOUNT" value="2" />
<input type="hidden" name="__VIEWSTATE" value="..." />
<input type="hidden" name="__VIEWSTATE1" value="..." />

Keep in mind that this won't improve the application performance. It will add more steps to serialize the data back before

being sent to the client.

Hope this helps,

Published 16 September 2008 04:13 PM by haissam


# mosessaur said on 18 September, 2008 08:14 PM

This won't improve the application performance, But if not needed just avoid it; because it might affect application performance.

This site



This Blog



  • MaximumASP