For some reason the viewstate of my application became gigantic (around 14 million characters). It adds around 1 minute of loading time. If the page finally loads (which is not often), the server crashes every time someone send a form because "Post size exceeded allowed limits.
"
It appeared suddenly. I didn't add any fields, just some javascript on the page.
People told me to check viewstate chunking out. Google told me to do this:
<pages maxPageStateFieldLength="1024">
... so now instead of a huge hidden field I now have something like 100 very large hidden fields. It's not exactly what I was looking for.
Why would .NET do something like this? How can I fix this?
I would suggest using a utility to decode your viewstate so you can get an idea of what is actually within it (since you obviously have a lot of information in there you don't seem to need.)
A viewstate decoder will allow you to see what's in your viewstate that you aren't expecting. Then you can either modify your code, remove the offending control, or selectively disable viewstate (using the EnableViewState="false"
attribute) for the controls that shouldn't have it enabled.
Keep in mind that controls will retain their values across postbacks without viewstate. You can often disable viewstate for a lot of your controls without any issues. To disable viewstate for a specific control set:
EnableViewState="false"
If you set this for all of your grids and any controls that you don't need viewsate for it will significantly reduce the size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With