Updated on Kisan Patel
This tutorial will explain you how to write Meta tags like author, robots, revisit-after etc. on the page in ASP.NET website?
Meta tags are generally used to instruct the Search engines to treat a page in specific manner. To add the Meta tags in ASP.NET page, you need to use the HtmlMeta
class and set its Name and Content properties as shown in below code:
protected void Page_Load(object sender, EventArgs e) { HtmlMeta author = new HtmlMeta(); author.Name = "author"; author.Content = "Kisan Patel"; this.Page.Header.Controls.Add(author); HtmlMeta robots = new HtmlMeta(); robots.Name = "robots"; robots.Content = "ALL"; this.Page.Header.Controls.Add(robots); HtmlMeta revisit = new HtmlMeta(); revisit.Name = "revisit-after"; revisit.Content = "30 days"; this.Page.Header.Controls.Add(revisit); }
This will add the Meta tag in HTML page as shown in below code:
.... <meta name="author" content="Kisan Patel" /> <meta name="robots" content="ALL" /> <meta name="revisit-after" content="30 days" /> </head> ...