0
我在我的網站的三個不同頁面上有三個不同的按鈕。有沒有一種方法可以根據按鈕的頁面動態創建和分配這些og標籤?如何在C#中動態分配不同的Facebook og標籤?
這裏是我一起工作的代碼:
protected void Page_Load(object sender, EventArgs e)
{
// ADD META INFORMATION TO HEADER
HtmlHead head = (HtmlHead)Page.Header;
// KEYWORDS
HtmlMeta hm = new HtmlMeta();
hm.Name = "keywords";
hm.Content = this.metaKeywords;
head.Controls.Add(hm);
// DESCRIPTION
hm = new HtmlMeta();
hm.Name = "description";
hm.Content = this.metaDescription;
head.Controls.Add(hm);
// ************************************************************************
// <meta property="og:title" content="Faces of Metastatic Breast Cancer (MBC) Video Wall" />
// <meta property="og:type" content="cause" />
// <meta property="og:image" content="http://www.facesofmbc.org/images/MBC_Logo.png"/>
// <meta property="og:url" content="http://bit.ly/rkRwzx" />
// <meta property="og:site_name" content="Faces of Metastatic Breast Cancer (MBC)" />
// <meta property="og:description" content="I just viewed the new Faces of Metastatic Breast Cancer (MBC) video wall. For each view, comment or share of the video wall during October, Genentech will donate $1 to MBC initiatives. Watch TODAY!" />
// <meta property="fb:admins" content="653936690"/>
string ogTitle = "";
string ogType = "";
string ogImage = "";
string ogUrl = "";
string ogSiteName = "";
string ogDescription = "";
string ogAdmins = "";
if (Page.Request.Path.Contains("videoWall.aspx"))
{
hm = new HtmlMeta();
hm.Attributes.Add("property", "og:title");
hm.Content = "TEST OG TITLE";
head.Controls.Add(hm);
hm = new HtmlMeta();
hm.Name = "og:type";
hm.Content = "TEST OG TYPE";
head.Controls.Add(hm);
}
// ************************************************************************
}
我知道這是錯誤的,似乎有不同的方法,但我只是顯示你我在做什麼和方向我正想。註釋掉的標籤只是作爲我需要的指南。任何幫助,將不勝感激!
在此先感謝!