Every ASP.NET developer (or at least most of us) wants a lot of visitors to their web sites. Google, Yahoo and other search engines can send plenty of visits especially if your web site is shown on first page of their search results. And vice versa, if your web site is shown on thirtieth page or not indexed you will not see any benefit of search engines. Because everyone wants to win first page there is strong competition and you need to take care of every factor that affects how much your page will be friendly to search engines.
There is more than a 100 important factors used from search engines to rank page. Most of them are just speculations, since Google, Yahoo and others don't want to reveal its ranking algorithm. Also, their algorithms are changed very frequently (a hundreds of times yearly) to improve user experience and provide correct results. Even Google has not capacity to manually change page ranking if they think that some page should be better or worse ranked. Instead, they try to find out what mistake in algorithm caused wrong ranking and try to correct it on that way. Because of that, Search Engine Optimization (SEO) is very dynamic field, but basics and most important things are still the same.
Create unique title for every page
Every page of web site needs to have its own unique title. Title should be short, descriptive, meaningful, contains keywords and relevant to content of the page. Do not insert repeated phrase like company name on the beginning of the title of every page. Let your most relevant information appears first. Title tag can be edited at design time, but if you have some content management system you can change it by using Page.Title property with code like this:
[ C# ]
Page.Title = "My unique and keywords rich title";
[ VB.NET ]
Page.Title = "My unique and keywords rich title"
When someone uses Google search, query terms will be showed as bolded text in search results. Because of this, you need to place targeted keywords in title to make it noticeable and therefore get more clicks to your site. Of course, to get a visit your title must please human visitors too, not just search engines. You can't just list keywords in title without any meaning. Instead of that, let your title tags be a precise descriptions of every single page and you'll be fine with both search engines and people. Don't use too long titles because search engines will truncate it anyway. Keep title under 65 characters long.
Use description and keywords meta tags
Description and keywords meta tags were very important for search engine optimization in past, but they are widely abused. Today meta keywords tag is practically useless, but meta description tag is still important. Although it would not improve your position in search results it is beneficial indirectly. Google often uses meta description tag when display search results below title as short description of your page. So, if you have catchy meta description tag you can get more visits even if you are not first in search results. Set unique page description for every page. Like page title, you can change meta tags in markup or dynamically in server side code:
[ C# ]
protected void Page_Init(object sender, EventArgs e)
{
// Add meta description tag
HtmlMeta metaDescription = new HtmlMeta();
metaDescription.Name = "Description";
metaDescription.Content = "Short, unique and keywords rich page description.";
Page.Header.Controls.Add(metaDescription);
// Add meta keywords tag
HtmlMeta metaKeywords = new HtmlMeta();
metaKeywords.Name = "Keywords";
metaKeywords.Content = "selected,page,keywords";
Page.Header.Controls.Add(metaKeywords);
}
[ VB.NET ]
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
' Add meta description tag
Dim metaDescription As HtmlMeta = New HtmlMeta()
metaDescription.Name = "Description"
metaDescription.Content = "Short, unique and keywords rich page description."
Page.Header.Controls.Add(metaDescription)
' Add meta keywords tag
Dim metaKeywords As HtmlMeta = New HtmlMeta()
metaKeywords.Name = "Keywords"
metaKeywords.Content = "selected,page,keywords"
Page.Header.Controls.Add(metaKeywords)
End Sub
This approach will also work if you use master pages
Using of H1 tag
H1 tag is very important, but in the same time very easy way to improve your position in search results. It is best if h1 tag has the same content like title tag. Just place same short, relevant, keyword rich phrase to both h1 and title tags and this single effort will significantly elevate your ranking. Like any other HTML tag, you can change h1 tag directly in markup, or dynamically if you add runat="server" and set its id, like in code bellow:
<h1 runat="server" id="MyPageHeader" ></h1>
Now you can manipulate h1 tag with ASP.NET server side code:
[ C# ]
MyPageHeader.InnerText = "This Is My Catchy Header";
[ VB.NET ]
MyPageHeader.InnerText = "This Is My Catchy Header"
There are also important <h2> and <h3> tags that you can use for sub headers and <strong> tag to make some keywords more significant in text.
ASP.NET SEO Url Redirecting
Sometimes you need to move a page to other url or move complete web site to other domain. Common example is, if you upgrade web site created in classic ASP to ASP.NET you need to change file extensions from .asp to .aspx. If some visitor comes to your old link from search engine or directly, he or she should be redirected to new url. There are two possible redirections:
1. Temporary redirection, returns message "302 Found". This redirection should be used only when necessary, very rarely for search engines optimization.
2. Permanent redirection, message returned is "301 Moved Permanently". This redirection tells spiders that page or site is moved to another url. It is used in SEO to transfer link popularity to new address.
SEO Friendly URLs: Url Rewriting
Web spiders don't like query strings parameters in urls. If you are getting some data from database, it is common to use query string like ShowProduct.aspx?id=23445. Although this url looks logical from programmer's perspective it is not user friendly and is usually not ranked well on search engines. You need to use urls that contain keywords separated by hyphens. So, instead of /ShowProduct.aspx?id?=23445 should be something like /My-Product-Name.aspx. Url that contains keywords is easier to read by human visitors and is better ranked on search engines. Also, site with SEO friendly urls is more secure since you can hide id or even file extension.
ViewState and SEO in ASP.NET
There is a speculation that search engines read only limited number of bytes from each page (first 100K of web page). ViewState value is a string presented as hidden field on client side. If you have large ViewState on the beginning of the ASP.NET page, then it is possible to web spiders avoid your real content. That could be harmful for your ranking in search results. The simple solution is to turn off ViewState if you don't need it, or at least not use it for every single control. A new property RenderAllHiddenFieldsAtTopOfForm has been included in .Net Framework 3.5 SP1. By setting its value to false, all system generated hidden fields will be rendered at the end of the form. But many developers misunderstand it and consider it to move viewstate to the bottom of the page which is wrong. This post explains very well what that property does and Microsoft Connect's post confirms that that property was introduced to solve problems with the EventValidation being at the bottom of the page and causing errors if the user submitted a postback before the EventValidation field had rendered. It also confirms that search providers no longer read only first 512 bytes of the page but whole page.