One simple recommendation to improve the search relevancy of
pages is to make sure you always output relevant “keywords” and “description”
<meta> tags within the <head> section of your HTML. For
One of the nice improvements with ASP.NET 4
Web Forms is the addition of two new properties to the Page class: MetaKeywords
and MetaDescription that make programmatically setting these values within your
code-behind classes much easier and cleaner.
ASP.NET 4’s <head> server control now
looks at these values and will use them when outputting the <head> section
of pages. This behavior is particularly useful for scenarios where you
are using master-pages within your site – and the <head> section ends up
being in a .master file that is separate from the .aspx file that contains the
page specific content. You can now set the new MetaKeywords and
MetaDescription properties in the .aspx page and have their values
automatically rendered by the <head> control within the master page.
Below is a simple code snippet that
demonstrates setting these properties programmatically within a Page_Load()
In addition to setting the Keywords and Description
properties programmatically in your code-behind, you can also now declaratively
set them within the @Page directive at the top of .aspx pages. The below
snippet demonstrates how to-do this:
As you’d probably expect, if you set the values
programmatically they will override any values declaratively set in either the
<head> section or the via the @Page attribute.