Microsoft .NET Viewstate and SEO
A few years ago when Microsoft introduced its .NET platform it also upgraded the languages and functionality available to web developers. One of the new features is called ViewState which is automatically generated code, hidden from users, that stores a user's current session data. Sounds good, right?
The problem is that the viewstate data can actually be quite lengthy. I've seen one example where this data was 77,000 characters long. It's hard to imagine what could possibly need that much code to store a user's session, but I double-checked and my count was correct. From a search engine optimization (SE0) perspective there are possible two problems with the ViewState code.
- As Bo Cakmak recent wrote in his examination of ViewState (page now gone so no link) search engines will only read the first 100K of a web page. Whether you agree with the 100K measure, it's reasonable 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've got a problem.
- The other issue 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. Again, I leave it up to you to decide if this is a valid concern.
The good news is that there are solutions to the ViewState issue. First off, in many cases the ViewState isn't actually needed, so just turn it off. When it is needed, there is a technique for moving it to the bottom of the web page. And finally for those up for a technical challenge, check out Peter Bromberg's article on moving ViewState to the cache or session. He includes code you can download too!