Set Meta Keywords and Description in ASP.NET Web Page

Published on Thursday, June 30, 2011

Before ASP.NET 4.0, you could add meta keywords and description using HTML in web page. In ASP.NET 4.0, you can set keywords and descriptions for your web pages declaratively.

There are two keywords MetaDescription and MetaKeywords in Page tag.

For example:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    MetaDescription = "This is Description" MetaKeywords="ASP.NET"   CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default"%>

The screen shot like following:


You can also put the Keywords and Description in code behind:

 protected void Page_Load(object sender, EventArgs e)
       Page.MetaDescription = "This is Description";
       Page.MetaKeywords = "ASP.NET";