In my opinion, VIEWSTATE is what which makes ASP.NET, ASP.NET. However this mode of memory, precisely the memory mechanism which stores the state, through a input type of hidden field might not work in those systems which has tight constraints over hidden vairables. This includes certain firewalls and proxies which restricts the hidden field to a certain limit. As the data withheld by these controls increases the size of this hidden field(__VIEWSTATE) increases, apparently and what results finally is the denial of VIEWSTATE and hence during the next phase on server side, the ASP.NET will fail to deserialize the user data.
But there is a way to overcome this problem. And that is what VIEWSTATE chunking is about. What VIEWSTATE chunking does is that, it simply divides the VIEWSTATE into set a hidden fields with a defined size limit. To perform that, go to the Web.config and provide the limit as shown below.
<configuration> .. <system.web> <pages maxPageStateFieldLength="20">... </pages> </system.web> </configuration>
The maxPageStateFieldLength parameter value is set to 20. Well, that is the number of bytes per each hidden field. Obviosuly, 20 bytes is very less and I did it for demonstraton only.
I have created a page with some text boxes. and filled it with values and created a button to perform Postback. And the following are the chunked STATE with set of values I received from the server.
<input type="hidden" name="__VIEWSTATEFIELDCOUNT" id="__VIEWSTATEFIELDCOUNT" value="5" /> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE4MTM5NTMz" /> <input type="hidden" name="__VIEWSTATE1" id="__VIEWSTATE1" value="MTgPZBYCAgMPZBYCAgEP" /> <input type="hidden" name="__VIEWSTATE2" id="__VIEWSTATE2" value="DxYCHgRUZXh0BQlzb21l" /> <input type="hidden" name="__VIEWSTATE3" id="__VIEWSTATE3" value="dGhpbmdkZGRmA1ctuFJC" /> <input type="hidden" name="__VIEWSTATE4" id="__VIEWSTATE4" value="RQdfo8rSra9Ik4399w==" />
Image source: flickr album of Cushing Memorial Library and Archives, Texas A&M’s.
Leave a comment