Free Search Engine Visibility Report

Newsletter Sign Up

First Name:

Last Name:

Email:

 

SEO Client
Results

Don't take our word for it, see our SEO results for yourself. When selecting a SEO firm make sure to ask for examples of their rankings. We only employ ethical SEO practices (white hat SEO practices) to achieve the best results for our clients.

View Results »

ASP.NET SEO Quick Tip – Moving SEO Unfriendly Code To the Bottom of the Page

http://www.morevisibility.com/seoblog/moving-seo-unfriendly-code-to-the-bottom-of-the-page.html August 25th, 2008 by

A common SEO technique is to make sure the content of your web page is placed as close to the top of your HTML as possible. This will help ensure that your relevant content achieves higher priority by search engine spiders. ASP.NET provides a great framework for developing feature rich web applications, especially with the addition of view state. View state gives web forms the ability to persist changes across postbacks. Other web scripting languages are not able to accomplish this easily, however, this benefit may have some negative SEO implications.

The view state of a page is placed by default in a hidden form field named ___VIEWSTATE at the top of the html source code. The contents of the __VIEWSTATE form field contain serialized information, which can get very large (tens of kilobytes), about various controls on the web page. When a web page does not have a lot of controls using view state, the hidden form field will look something like this…

20080815-top

… which is probably fine at the top of the page. But, often times a web page may have numerous controls, no matter how much it is optimized to minimize view state, which produce a view state value that looks something like this…

20080815-bottom

… actually it could go on and on. This particular view state sample (this is just a small portion) was 10 pages long! Needless to say, you don’t want that to appear before your precious web page content.

There is an easy way to move the __VIEWSTATE form field to the bottom of the html source code. By pasting the following VB.NET code, “as is”, into your web form, the view state will be moved to the bottom of the html source code right above the closing </form> tag…

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)<br />
Dim stringWriter As System.IO.StringWriter = New System.IO.StringWriter<br />
Dim htmlWriter As HtmlTextWriter = New HtmlTextWriter(stringWriter)<br />
MyBase.Render(htmlWriter)<br />
Dim html As String = stringWriter.ToString()<br />
Dim StartPoint As Integer = html.IndexOf("<input /><br />
If StartPoint >= 0 Then<br />
Dim EndPoint As Integer = html.IndexOf("/>", StartPoint) + 2<br />
Dim viewstateInput As String = html.Substring(StartPoint, EndPoint - StartPoint)<br />
html = html.Remove(StartPoint, EndPoint - StartPoint)<br />
Dim FormEndStart As Integer = html.IndexOf("") - 1<br />
If FormEndStart >= 0 Then<br />
html = html.Insert(FormEndStart, viewstateInput)<br />
End If<br />
End If<br />
writer.Write(html)<br />
End Sub

Now when you browse your web page, the __Viewstate hidden form field and its ridiculously long value, will be at the bottom of the page, and your precious content will be closer to the top, just how the search engines like it.

Posted in SEO & Technology

Comments are closed at this time.


Subscribe rss feed Login or Register

Recent Articles

Article Categories

Articles by Month

Related Sites


Inc 5000 Google Analytics Authorized Consultant Google Qualified Company Microsoft adExcellence Member Greenified 2009

MoreVisibility
925 South Federal Highway, Suite 750
Boca Raton, FL 33432 www.morevisibility.com

800.787.0497

ph: 561.620.9682

fx:  561.620.9684


© 1999 - 2012 MoreVisibility ® All Rights Reserved. Privacy | Legal

MoreVisibility Social Networking Links Google+ YouTube LinkedIn Facebook Twitter