C#在后台如何添加keywords和description?
现在写个通用的类
/// <summary>
/// 添加meta中keywords,和description
/// </summary>
/// <param name="MetaType">metal类型</param>
/// <param name="page">页面</param>
/// <param name="MetaContent">metal内容</param>
public static void GetMetaType(int MetaType, System.Web.UI.Page page, string MetaContent)
{
System.Web.UI.HtmlControls.HtmlMeta meta = new System.Web.UI.HtmlControls.HtmlMeta();
switch (MetaType)
{
case 1: meta.Name = "keywords";
break;
case 2:
meta.Name = "description";
break;
case 3:
page.Header.Controls.Add(new System.Web.UI.LiteralControl("/n/r"));
break;
}
if (MetaType == 3) return;
meta.Content = MetaContent;
page.Header.Controls.Add(meta);
page.Header.Controls.Add(new System.Web.UI.LiteralControl("/n/r"));
}