Just a small snippet to add link rel=”canonical” tag to your aspx pages using c#
We can use the canonical tag to tell the search engines to discard duplicate pages.
HtmlLink tag= new HtmlLink(); tag.Attributes.Add("rel", "canonical"); tag.Href = "http://www.yourdomainurl.com"; Header.Controls.Add(tag);
if you see a red underline in HtmlLink object, because if it does not has the namespace. Just right-click on it and select resolve and add the namespace. The namespace will be
using System.Web.UI.HtmlControls;