我在网站的三个不同页面上有三个不同的点赞按钮。有没有办法根据按钮所在的页面动态创建和分配这些 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);
}
// ************************************************************************
}
我知道这是错误的,并且似乎有不同的方法,但我只是向您展示我在做什么以及我前进的方向。注释掉的标签只是作为我需要哪些标签的指南。任何帮助,将不胜感激!
提前致谢!