Reply to comment
ASP.NET Programatically Add META Keywords and META Description Tags
One important part of any ASP.NET page is adding a META Keywords and META description tag to the HEAD section of the page. Many search engines place significant weight on the presence of these two tags.
There is some disagreement between SEO experts on how much weight is actually put on these tags by search engines like Google, but it is generally accepted that these tags should be present on any page that you wish search engines to index. Unfortunately, this is usually an after thought for many ASP.NET projects.
Of course, the simplest way to add these tags is manually to the HTML part of your ASP.NET page like this:
<meta name="description" content="your description goes here..." /> <meta name="keywords" content="keywords are listed here with a comma" />
But what if you want to add these tags programmatically in the Page_Load event or other code behind method of your page? If you are using ASP.NET 3.5 or lower, you can add the tags like this:
// add meta description towards the top of the HEAD tag on the page System.Web.UI.HtmlControls.HtmlMeta metaDescription = new System.Web.UI.HtmlControls.HtmlMeta(); metaDescription.Name = "description"; metaDescription.Content = "your description goes here..."; Page.Header.Controls.AddAt(1, metaDescription); // add meta keywords towards the top of the HEAD tag on the page System.Web.UI.HtmlControls.HtmlMeta metaKeywords = new System.Web.UI.HtmlControls.HtmlMeta(); metaKeywords.Name = "keywords"; metaKeywords.Content = "keywords are listed here with a comma"; Page.Header.Controls.AddAt(1, metaKeywords);
In ASP.NET 4.0 or higher, there is an easier way because of the new built in page methods like this:
Page.MetaDescription = "your description goes here..."; Page.MetaKeywords = "keywords are listed here with a comma";
Reply
Popular Articles
Last viewed:
- C# Download File with Progress Bar
- Install Windws 2003 Terminal Service Licenses (Remote Desktop)
- SQL Create Table Add Description to Column
- Windows Server 2003 Configure RRAS (Routing and Remote Access Service) Site to Site VPN
- SQL Server Log File (AKA LDF file) is huge - reduce size
- Using Nullable Data Types with C#

Recent comments
1 day 18 hours ago
6 days 8 hours ago
6 days 9 hours ago
1 week 18 hours ago
1 week 2 days ago
2 weeks 8 hours ago
2 weeks 1 day ago
2 weeks 4 days ago
2 weeks 6 days ago
2 weeks 6 days ago