ASP.NET 4.0 Features - MetaDescription and MetaKeywords

Abhijit Jana
Posted by in ASP.NET category on for Beginner level | Views : 45536 red flag

ASP.NET 4.0, came up with two new properties inside Page Class, those are MetaDescription and MetaKeyWord. This has been introduce because of make web application Search Engine Friendly. Search Engine looks for Meta tag of our web page to get the details of page contents. In ASP.NET 4.0, we can add these two properties with page class in Code behind or in Page Directives.
Introduction
ASP.NET 4.0, came up with two new properties inside Page Class, those are MetaDescription and MetaKeyWord. This has been introduce because of make web application Search Engine Friendly.  Search Engine looks for Meta tag of our web page to get the details of page contents.  In ASP.NET 4.0, we can add these two properties with page class in Code behind or in Page Directives.

If you want to find out the definition of these two properties, Right Click on Page Class and Click on Goto Definition. This will show you the Meta data information of Page Class as shown in below picture.


Fig:Page Class with MetaDescription and MetaKeyWords Properies
How to use ?


If we set MetaDescription and MetaKeywords either from Code behind or using Page Directive in aspx page, both will be render as “meta” tag in html code.
Let have a look, how we can set these two properties from code behind,

protected void Page_Load(object sender, EventArgs e)

{

Page.MetaKeywords = "ASP.NET 4.0, .NET 4.0";

Page.MetaDescription = "ASP.NET 4.0 Information";

}



Fig: Set MetaKeywords and MetaDescription Properties using Codebehind

Now, If I run the application and check the HTML rendered content we will found the following code,

<head>

<meta content="ASP.NET 4.0 Information" name="description" />

<meta content="ASP.NET 4.0, .NET 4.0" name="keywords" />

</head>

Similarly we can also add MetaKeywords and MetaDescription Properties  in Page Directive Itself. 


But the HTML output will be same for both the case.

Fig: HTML Rendered content of MetaKeywords and MetaDescription

Conclusion
The main objective of MetaKeywords and MetaDescription proerties to make your web application SEO friendly. In ASP.NET 2.0, HtmlMeta used to do the same, but in ASP.NET 4.0 make these thing  very simple as we can easily add using Page Class.
Please share your feedback and suggestion to improve this article.

Reference :
ASP.NET 4.0 Features

Page copy protected against web site content infringement by Copyscape

About the Author

Abhijit Jana
Full Name: Abhijit Jana
Member Level: Bronze
Member Status: Member,MVP
Member Since: 12/24/2008 11:28:35 PM
Country: India
Cheers ! Abhijit
http://abhijitjana.net
He has done Master Degree in Computer Application and currently working as a Sr. S/W Developer in a US based MNC and having more than 3 years exp. He has worked with all the .NET framework and good exposer in Web and Windows based development using Microsoft Technology . Currently he working with C# 3.5, ASP.NET 3.5, Enterprise Library 4.1 and SDL Tridion also Exploring VS 2010 with .NET 4.0.

Login to vote for this post.

Comments or Responses

Posted by: Sashidhar.ssd on: 3/1/2010
Nice One as always..!

Login to post response

Comment using Facebook(Author doesn't get notification)