最简单的设置Title和关键字方法,方便你做搜索引擎检索

public class PageSeo
    {
        public static void getSeoInfo(string pages)
        {
            try
            {
                string strsql = "select title,keyword,description from pageSeo where page='" + pages + "'";
                DataSet ds = ErnieManager.getDatasetByStrsql(strsql);
                if (ds.Tables[0].Rows.Count < 0)
                {

                }
                else
                {
                    string titleInfo = "<title>" + ds.Tables[0].Rows[0]["title"] + "</title>";
                    string keywordInfo = "<meta name=\"keywords\" content=\"" + ds.Tables[0].Rows[0]["keyword"] + "\" />";
                    string description = "<meta name=\"description\" content=\"" + ds.Tables[0].Rows[0]["description"] + "\">";
                    System.Web.HttpContext.Current.Response.Write(titleInfo + keywordInfo + description);
                }
            }
            catch (Exception ex)
            {
            }
        }
    }

很久很久之前写的,方法也许不是太好,期待有你的更好办法!

qq讨论群  :  171560784

posted @ 2013-04-28 11:50  kezhiping  阅读(299)  评论(0编辑  收藏  举报