ASP .Net Page.Header with custom meta tags 1


One of this days a friend of mine shared with me some SEO techniques and one of them was to change the meta tags associated with a product page. So after a little research I found out a way to accomplish this : modify the Header property of ASP .Net page and add several HtmlMeta tags who can hold the data needed to be changed.

Each ASP .Net page has a property called Header who is the “hidden” header code of each HTML page. It is available starting with .Net version 2.0 and exposes also the meta tags object collection. Actually, all elements in the header are available in Header.Controls

// Render:  HtmlMeta meta1 = new HtmlMeta(); meta1.Name = "keywords"; meta1.Content = "pharmacy, online pharmacy, home delivery";   // Render:  
HtmlMeta meta2 = new HtmlMeta();
meta.Name = "verify-v1";
meta.Content = "DmMArCJQq9KV45wvKMwrWASh3R8UWTd7NfBD";

// Render:
HtmlMeta meta3 = new HtmlMeta();
meta.Name = "revisit-after";
meta.Content = "2 days";

Header.Controls.Add(meta1);
Header.Controls.Add(meta2);
Header.Controls.Add(meta3);

Leave a comment

Your email address will not be published. Required fields are marked *