Click here to Skip to main content
14,268,557 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have just got a quick question. When we give the config settings as

maxPageStateFieldLength = "2048"


then the value 2048, is that the number of characters or if it is the size of the hidden field then what is the unit of it like bytes etc?

Also, how do we know what value can we give for our project?

Can anyone please help me to find out the answers for these questions

What I have tried:

<pages enableEventValidation="false" controlRenderingCompatibilityVersion="4.0" maxPageStateFieldLength="2048">
Posted
Updated 8-Aug-19 1:39am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Always refer to the documentation page:
Page.MaxPageStateFieldLength Property[^]

is that the number of characters or if it is the size of the hidden field then what is the unit of it like bytes etc?
This is the maximum length, in bytes, of the page's state field.

how do we know what value can we give for our project?
Having an idea of the average size for the state field in your project is a start. Or, you can set it to -1 as suggested in the documentation, and forget about it (unless this setting cause some sort of actual issue).
   
Comments
user 3008 8-Aug-19 8:49am
   
I actually have an issue with my ViewState, where it is intermittently throwing an error occurred in a few pages in my project and so I am trying to add the maxPageStateFieldLength in the config settings. But I am not sure what value should I have to give. I tried with 40/60 but still got the issue. Now I have given the value as 2048 and no errors till now. I am not sure whether I have given very high value than needed for my project.
phil.o 8-Aug-19 9:09am
   
2048 bytes (2 Kb) does not seem so huge nowadays. If it solved your issue, without causing timeouts or other unpredicted results, then I would say it fits.
If you still wonder whether or not it is appropriate, then log view states' sizes somewhere in your server code, and try to optimize the value with acquired knowledge.
user 3008 8-Aug-19 10:08am
   
Thank you so much for your help. I just found that the view state for my page is 59928 and so even 2048 also didn't work. Now set the value to 59930. Fingers crossed
phil.o 8-Aug-19 10:32am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100