asp.net 設定Meta

來源:互聯網
上載者:User

Meta標籤無疑對網站宣傳是有很大作用的,搜尋引擎通過Meta標籤得到網頁的相關資訊,如Keywords,Description等等內容。如果用Asp.Net來進行動態產生頁,特別是使用模板頁,似乎無法為每個網頁加入Meta資訊,其實不然,完全可以用編程的方式為自己的aspx頁加入Meta資訊。

     protected void Page_Load(object sender, EventArgs e)
     {
         HtmlMeta metaKeyWords = new HtmlMeta();
         HtmlMeta metaDescription = new HtmlMeta();

         metaKeyWords.Name = "Keywords";
         metaKeyWords.Content = "牛奶";
         metaDescription.Name = "description";
         metaDescription.Content = "**牌牛奶";
         Header.Controls.Add(metaKeyWords);
         Header.Controls.Add(metaDescription);
     }

可以把Keywords和Description存入資料庫,動態檢索出來,並為網頁配置即可,值得注意的是多個標記要用多個HtmlMeta進行添加,再加入到Header中。

原始路徑:http://hi.baidu.com/lieqer/blog/item/b67cef829e019392f603a60b.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.