Aug 16, 2013

Page.MetaKeywords and Page.MetaDescription

Page.MetaKeywords and Page.MetaDescription - ASP.Net 4.0

One of the additions that has been made to ASP.NET 4 is the addition of two properties to the Page class, MetaKeywords and MetaDescription.

To increase the relevance of pages in searches, developers should include relevant “keyword” and “description” meta tags in the html section.     Unfortunately, it takes some time to add these tags for each and every page, and the alternative of adding these tags programmatically was difficult.

Meaning of these two properties:
  • Page.MetaDescription – equivalent to meta name “description”
  • Page.MetaKeywords – equivalent to meta name “keywords”


They follow these rules:
  • If there are no meta tags in the head element that match the property names, the meta tags will be added to the page when it is rendered.
  • If there are already meta tags with these names, these properties act as get and set methods for the contents of the existing tags.


You can set these properties at run time, which lets you get the content from a database or other source, and which lets you set the tags dynamically. You can also set the keywords and description properties in the @Page directive at the top of the page markup.

This will even be useful for Master pages—where you only have to add these properties in the master page. In addition to “keywords” and “description” settings in the code behind, developers can also set these values within the @Page directive.


No comments:

Post a Comment