What is an optimal value for maxPageStateFieldLength in ASP.NET

老子叫甜甜 提交于 2019-12-08 15:54:03

问题


In pages that have a viewstate that spans 10-15KB what would be an optimal value for

<pages maxPageStateFieldLength="">

in the web.config in order to reduce the risk of potential truncation leading to viewstate validation errors?


回答1:


The maxPageStateFieldLength doesn't limit the size of the view state, so it won't be truncated.

What it does is simply control how much of the view state will be placed in one hidden field. If the view state is larger than the maxPageStateFieldLength value the view state will simply be split into several hidden fields.

The default value is -1, meaning that the view state is put in a single hidden field, which is normally the most optimal.




回答2:


I am currently running into a problem where we are getting "HttpException Due to Invalid Viewstate" errors for only Firefox users. I am also seeing "System.Web.HttpException: An error occurred while communicating with the remote host. The error code is 0x80070001" exceptions paired up with the viewstate ones.

I believe that firefox has possibly got a max size on (possibly) hidden form fields - i need to verify this. I'm now looking to chunk up the viewstate using maxPageStateFieldLength to hopefully resolve (in the short term). The longer term solution is to refactor the aspx page to do a paging query for grid (instead of pulling down all the rows in one go - which is not a good thing to do).

IMHO, you should put in a maximum that is fairly large but not unlimited. I'd say 1MB is a start.



来源:https://stackoverflow.com/questions/2585154/what-is-an-optimal-value-for-maxpagestatefieldlength-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!