ASP.NET 2.0: ViewState Numbers
Although they still use it as if nothing was the matter, some people are a bit worried about viewstate and security. My personal opinion is that you should be concerned about the view state, but not for the potential security holes it might open in your code—unless you love shooting yourself in the foot. You should be more concerned about the overall performance and responsiveness of the page. Especially for feature-rich pages that make use of plenty of controls, the view state can reach a considerable size, measured in KB of data. Such an extra burden taxes all requests, in download and upload, and ends up being a serious overhead for the application as a whole. Let's review some numbers trying to learn from best practices.
You should endeavour to keep a page size around 30 KB, to the extent that is possible of course. For example, the Google’s home page is less than 4 KB. The home page of ASP.NET counts about 50 KB. The Google’s site is not written with ASP.NET so nothing can be said about the viewstate; but what about the viewstate size of the home of the ASP.NET site? Interestingly enough, that page has only 1 KB of viewstate. On the other hand, this page on the same site (ASP.NET) is longer than 500 KB of which 120 KB is viewstate.
The ideal size for a viewstate is around 7 KB; it is optimal if you can keep it down to 3 KB or so. In any case, the viewstate, no matter its absolute size, should never exceed 30% of the page size.
PS1: In ASP.NET 2.0, a new serialization format (incorporated in a new formatter class, ObjectStateFormatter), significantly cuts down the size of the viewstate by about 50%. Which is just great! All that you have to do is recompile...
PS2: All numbers mentioned are based on the size of the pages as of July 20, 2005.