One of the smaller additions we’ve made to ASP.NET 4.0 WebForms is the addition of two properties on the Page class, Page.MetaKeywords and Page.MetaDescription.
What these two properties do is provide access to / create meta tags within your page as follows:
<head runat="server">
<title>Untitled Page</title>
<meta name="keywords" content="These, are, my, keywords' />
<meta name="description" content="This is the description of my page" />
</head>
Simple, right? In fact these two properties work the same way as Page.Title works:
1. If there are no meta tags in the head element matching the property names e.g., name=”keywords” for Page.MetaKeywords and name=”description” for Page.MetaDescription then we create these tags and fill in the string you entered as the content.
2. If there are already meta tags with these names we provide get / set access to the existing tags…
Of course you can set these in code, so the content could come from a DB to describe what you particular page is for etc…
Oh, and you can also set these in the Page tag at the top of your WebForm as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Metaeywords="Hello" MetaDescription="This is my description" %>
This will override the meta tag contents (if any) already declared in the page.
Note, that the description in these tags is only really used for improving your snippets on Google, Google and Live don’t use the Keywords for anything but other search engines may.
A simple feature but it is pretty useful (and saves you messing about with adding these manually / writing your own code to create these.