In pages that have a viewstate that spans 10-15KB what would be an optimal value for
<pages maxPageStateFieldLength="">
in the开发者_C百科 web.config in order to reduce the risk of potential truncation leading to viewstate validation errors?
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.
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.
精彩评论