ViewState too large and setting the max number of controls in the one page by web config
来源:互联网 发布:淘宝网中年女装40岁 编辑:程序博客网 时间:2024/05/17 12:52
From:
http://weblogs.asp.net/lduveau/archive/2007/04/17/viewstate-chunking-in-asp-net-2-0-maxpagestatefieldlength.aspx
ViewState Chunking in ASP.NET 2.0 (maxPageStateFieldLength)
I am currently teaching an ASP.NET 2.0 course in Quebec city. I like it because each time I give a training I learn something (and so do my trainees I hope...). This time I learnt something new about the ViewState.
When ViewState in your page become very large it can be a problem as some firewalls and proxies will prevent access to pages containing such huge ViewState sizes. For this purpose ASP.NET 2.0 introduces theViewState Chunking mechanism.But the first thing I would say is if your ViewState is that big ask yourself why, and the way to optimize (maybe disabling?) it.
So ASP.NET 2.0 enables to split the ViewState's single hidden field into several using theMaxPageStateFieldLength property in the web.config <pages> section. This indicates the maximum bytes size allowed for one viewstate hidden field. If the real size exceeds the value then viewstate is splitted in multiple fields. By default, the attribute is set to -1 which means that no maximum size is defined.
Sample ViewState before:
<input type="hidden" name="__VIEWSTATE"id="__VIEWSTATE"
value="/wEPDwUKLTk2Njk3OTQxNg9kFgICAw9kFgICCQ88KwANAGQYAQUJR3Jp
ZFZpZXcxD2dk4sjERFfnDXV/hMFGAL10HQUnZbk=" />
Then set in web.config:
<pages maxPageStateFieldLength="40">
Sample ViewState After :
<input type="hidden" name="__VIEWSTATEFIELDCOUNT"id="__VIEWSTATEFIELDCOUNT"
value="3"/>
<input type="hidden" name="__VIEWSTATE"
id="__VIEWSTATE"value="/wEPDwUKLTk2Njk3OTQxNg9kFgICAw9kFgICCQ88"/>
<input type="hidden" name="__VIEWSTATE1"
id="__VIEWSTATE1"value="KwANAGQYAQUJR3JpZFZpZXcxD2dk4sjERFfnDXV/"/>
<input type="hidden" name="__VIEWSTATE2"
id="__VIEWSTATE2"value="hMFGAL10HQUnZbk="/>
Please note THIS IS NOT a way to optimize ViewState size!! This is a way to fix a possible technical problem with huge ViewState size and firewall.
setting the max number of controls in the one page by web config
<appSettings>
<addkey="aspnet:MaxHttpCollectionKeys" value="5000" />
<addkey="aspnet:MaxJsonDeserializerMembers" value="5000" />
</appSettings>
- ViewState too large and setting the max number of controls in the one page by web config
- the large number of gemstones
- config the Cache in the file of Web.Config
- packet for query is too large <1781> 1024 >. you can change this value on the server by setting the
- Packet for query is too large (1029 > 1024). You can change this value on the server by setting the
- Packet for query is too large (1032 > 1024). You can change this value on the server by setting the
- checkbox in the panel control under control of one page
- Count the number of alphabets, spaces, digits and other characters in one line character
- how to extend the base functionality of standard web controls - by Venugopal Mallarapu
- the setting of vim in ubuntu11.10
- The difference between the request time and the current time is too large.
- We are already in the process of making 6 connections and the number of simultan
- How To Print a Form That Is Too Large for the Screen or Page
- Setting the -source and -target of the Java Compiler
- compute the MAX and MIN of int
- How to get the content of the 'identity' section in web.config
- Back to Top in the web page
- Find the first minimum number and the second one.
- 云计算数据中心运维管理要点
- 解决Xcode 4.3.2的"Could not insert new outlet connection"问题
- 新白娘子传奇
- NSString的比较
- 写给五岁生日的可可宝宝
- ViewState too large and setting the max number of controls in the one page by web config
- Incrementing Counts in SQL
- C语言中sizeof与strlen区别
- extern "C"详解
- poj3041 二分图的最小点覆盖
- linux学习路线浅谈(转载)
- cookie使用
- db2 中出现SQL0449 错误处理
- 一步一步走进字符驱动--自旋锁