Tag Archives: asp.net

One of the innovative features that Microsoft introduced in its .Net platform is called ViewState which is automatically generated code, hidden from users, that stores a user’s current session data.

Viewstate adds some hidden fields to your website. Viewstate includes Meta data to the source code. For the reason that search engines, like Google, focus on the first part of the source code – so if the source code of your ASP.NET website begins with these hidden fields for viewstate, Google will have small problems to find out, what your page is about. As a final point, your page will suffer a bad ranking, even if your content is the best there is. Just because of unoptimized source code.

The complexity is that the viewstate data can really be quite lengthy. It’s tough to visualize what could possibly need that much code to store a user’s session. As per the recent assessment search engines will only read the first 100K of a web page. Whether you agree with the 100K measure, it’s sensible to expect that pages beyond some size will not be downloaded in full by search engines. If the ViewState code pushes a web page beyond this threshold, you have got a problem.

The further problem that some people might be concerned about is whether all of this code dilutes the page i.e. the code to text ratio is high.

The excellent information is that there are solutions to the ViewState problem. First off, in many cases the ViewState is not really needed, so just turn it off. When it is needed, there is a method for moving it to the bottom of the web page.

Use viewstate only if it is necessary

Viewstate is valuable, whenever a page posts back to itself. Whenever this does not happen, just deactivate viewstate.

The lack of the implementation is, that you may deactivate viewstate but ASP.NET will defiantly render a viewstate when a form exists with runat=server. So if you really want to keep viewstate out of your ASP.NET website AND want to use form runat="server" you can avoid viewstate at all: