Daily Archives: April 21, 2010

MetaKeyword and MetaDescription – SEO Feature of ASP.Net 4.0

The meta tag is recommended in order to improve the search relevancy of a page. Meta tag allows Web page authors to give a more meaningful description for listings, if the search engine is unable to create automatically its own description based on the page content. We use meta tag within the head section of page’s HTML.

For example –

<html xmlns=”http://www.w3.org/1999/xhtml“>

<head runat=”server”>

<title>Product List</title>

<meta name=”keywords” content=”keyword1, keyword2, keyword3, keyword4″ />

<meta name=”description” content=”put page description here” />

</head>

Now in Page class of ASP.net 4.0 two properties MetaKeyword and MetaDescription have been added to set the meta tag dynamically.

Let’s see how to set meta keywords and description to a page dynamically.

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Page.MetaKeywords = “keyword1, keyword2, keyword3, keyword4″;

Page.MetaDescription = “put page description here”;

}

}

If we run the application and see the page source. It looks something like this

<head runat=”server”>

<title>Product List</title>

<link href=”~/Styles/Site.css” rel=”stylesheet” type=”text/css” />

<meta name=”description” content=”put page description here” />

<meta name=”keywords” content=”keyword1, keyword2, keyword3, keyword4″ />

</head>