The HTML <META> tag is used to store information about a page. Including <META> tags in your pages may make your site more search engine friendly. <META> tags must be nested immediately under the <HEAD> tag. You can specify a page's keywords and description with <META> tags. For example, the old ASP.NET implementation of my articles.aspx page had the following <META> tags:
<meta name="keywords" content="Articles, Eric Bergman-Terrell, S3, .NET, C#, dotnet, Web Services, ASP.NET, Windows Forms" /> <meta name="description" content="Magazine articles written by Eric Bergman-Terrell" />
You can programmatically add <META> tags to your pages as follows by populating an HtmlMeta object and inserting it in the page's Header.Controls container. For example, I use the following code to add <META> tags to pages on my site. The keywords object is a DataSet that contains keywords and descriptions for most of the pages on the site:
private void AddMetaTags()
{
if (keywords != null)
{
string filter = string.Format("Page = '{0}'", Request.Url.AbsolutePath);
DataRow[] rows = keywords.Tables[0].Select(filter);
if (rows.Length == 1)
{
string keywordText = rows[0]["Keywords"] as string;
string descriptionText = rows[0]["Description"] as string;
if (keywordText != null || descriptionText != null)
{
if (keywordText != null)
{
// Create a META tag.
HtmlMeta meta = new HtmlMeta();
meta.Attributes.Add("name", "keywords");
meta.Attributes.Add("content", keywordText);
Header.Controls.Add(meta);
}
if (descriptionText != null)
{
// Create a META tag.
HtmlMeta meta = new HtmlMeta();
meta.Attributes.Add("name", "description");
meta.Attributes.Add("content", descriptionText);
Header.Controls.Add(meta);
}
}
}
}
}
| Title | Date |
| Vault 3: How to Include Outline Text in Exported Photos | October 26, 2025 |
| .NET Public-Key (Asymmetric) Cryptography Demo | July 20, 2025 |
| Raspberry Pi 3B+ Photo Frame | June 17, 2025 |
| EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
| Vault 3 Security Enhancements | October 24, 2023 |
| Vault 3 is now available for Apple OSX M2 Mac Computers! | September 18, 2023 |
| Vault (for Desktop) Version 0.77 Released | March 26, 2023 |