Article posted by
Abhijit Jana on 3/1/2010 | Views: 9227 | Category:
ASP.NET | Level: Beginner
If you found
plagiarised (copied) or inappropriate content,
please
let us know the original source along with your correct email id (to communicate) for further action.
Advertisements
Advertisements
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
If you like this article, subscribe to our RSS Feed . You can also subscribe via email to our Interview Questions, Codes and Forums section.
Found interesting? Add this to: