Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

ASP.NET 4.0 SEO features: Description and keywords

Another new SEO feature that ASP.NET 4.0 introduces is support for meta description and keywords. I think these are the most abused SEO features ever and search engines are very careful when considering these meta tags but I am very sure that there are still engines that respect those tags and that’s what makes these new features very useful.

Let’s see now how to set meta keywords and description to page. At first let’s create empty ASP.NET page and let’s see through browser the mark up of this page. Mark up should look something like this.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>
  
</title>
</head>

<body>

Now let’s write Load event for page. In this event we set meta description and keywords programmatically. Just take the following code in language you prefer.

C#
protected void Page_Load(object sender, EventArgs e)
{
    Page.MetaDescription = "This is my rabbits page";
    Page.MetaKeywords = "rabbit, rabbits, bunny, bunnies";
}

VB.NET


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Page.MetaDescription = "This is my rabbits page"
    Page.MetaKeywords = "rabbit, rabbits, bunny, bunnies"
End Sub

Let’s run web application again and see page source through browser again. You should see something like this.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>

</title>
<meta name="description" content="This is my rabbits page" />
<meta name="keywords" content="rabbit, rabbits, bunny, bunnies" />
</head>

<body>

There is one little thing that is annoying for me: meta tags are not splitted to separate lines. To make mark up easier to read I had to insert line breaks manually. But server-side code, as you can see, is simple and straightforward.


kick it on DotNetKicks.com vote it on Web Development Community pimp it Progg it Shout it
Posted: May 27 2009, 12:38 PM by DigiMortal | with 24 comment(s)
Filed under: ,

Comments

seo said:

It is a good blog, nice content also. Thanks for sharing such a good blog.

# May 27, 2009 7:19 AM

Susan Reed said:

Can you do the same thing with your cananonical tag?

# September 21, 2009 5:01 PM

LexarDS said:

Thanks for the info

Is therer any supports for keywords in contentpages?

I mean... if you add meta definitions in the content page, they wont overwrite the masterpages definitions, they will duplicate

Thanks

# September 21, 2009 8:09 PM

seo said:

Great addition and thanks for sharing. Yes, the meta data is the most abused as far as seo goes but we believe that it is still very valid in a few ways. Keywords may not get 'looked' at with the same importance by engines but having a few of the main ones can never hurt. The main reason they are abused is for keyword stuffing and repetition, so be sure to only use your main keywords for that page and be sure the content is related to those keywords. The meta description should have your main keyword (first of your meta keywords) in there and then remember this is what comes up in the SERP (search engine results page) so make this catchy and be the answer to what people are looking for in relation to their keywords.

# October 8, 2009 4:48 AM

Beyonce said:

Superb Blog! Kudos on the awesome work!

# January 7, 2010 7:51 PM

mildura seo said:

Thanks for sharing, i never knew how to do that and i've been looking for a while!

# August 24, 2010 6:53 AM

solar pv panels said:

thanks for sharing this .

# May 23, 2011 7:14 AM