just wanna ask what is acceptable size of ViewState per page? What is the level I should start worried.
Is there any objective measurement for viewstate size?
Thanks for any opinion :-) Cheers, X.
What is ViewState? ViewState is a client side mechanism. It stores the value in the page itself. Preserving the value of page controls between client to server and server to client is called "roundtrip". It stores the page or control value in the mode of hidden fields.
You can check viewstate on executed ASP.NET page by viewsource from browser. There you can find _VIEWSTATE kind of hidden field. ViewState increases the size of the page because page and page control value store in it.
View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
By default, view state data is stored in the page in a hidden field and is encoded using base64 encoding. In addition, a hash of the view state data is created from the data by using a machine authentication code (MAC) key.
This would depend on your end-users.
For a internal application where the size of the page is not an important criteria, I would not worry too much about it.
Viewstate is not a problem in itself, it is a problem when it starts slowing down your application because it sends this viewstate back and forth between your client and your server.
You have to consider that the viewstate is sent to the user to be rendered in the source of the page, but it will also be sent back to your server to keep the state of this page, and it will be loaded in memory.
If your end users have a slow internet connection, the bigger the page is , the slower and the more painfull it will be for them.
If your hosting provider is billing you depending on the data transfered, you might want to reduce it as much as possible too. especially if you have a lot of users...
Also consider the memory available on your server as the viewstate is loaded in the RAM for each request, for each user.
You need to make it smaller than a Borg Cube:
http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx
ViewState will add your web app's distinctiveness to it's own. Performance is futile.
I think it basically depend on what you have to achieve, and how much you are using it for "intentional" purposes. Anyway there are ways to measure, decode and optimize it:
http://jagbarcelo.blogspot.com/2009/03/viewstate-size-minimization.html
https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5229520.html
http://scottonwriting.net/sowblog/posts/4409.aspx
It depends.....If you have 1 user then size is not as important compared to if you have a million users. You also need to know how much RAM you have and if you are running out of RAM
I'm not sure that there is an "acceptable size" for a viewstate - it just depends on the size and complexity of your page. I know that its easy for it to become bloated and much bigger than it needs to be - a couple weeks ago we decoded our viewstate and found we could reduce it by about 40% on some of our larger pages.
Your viewstate should be as big as it needs to be. Just make sure to keep an eye on it to make sure it isn't bloating up with information that is completely unnecessary to a postback.
It depends on a lot of factors. A page with a lot of controls & content will have a lot more viewstate. What's acceptable, depends on the bandwidth limitations you have. If it's an internal company application and doesn't have a lot of users, a bigger viewstate(200-500k) may be acceptable. If it's on the web or a lot of users will be on it, you should limit the viewstate.
To limit viewstate, look at ways to improve your UI so it's not as complicated. Modal pop ups such as the Telerik RadWindow to are a good way to move some controls out to another page, while preserving the interaction between the pages.
On complicated pages, Tabs are also a good way to improve UI..each Tab can be it's own page.
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