Tùy biến Meta Description và Meta Keywords trong ASP.NET
Khi tạo website asp.net bạn có thể dễ dàng tùy biến Title của website thông qua thuộc tính Page.Title tại sự kiện Page_Load nhưng bạn muốn website của mình thân thiện với Search Engine hơn qua việc thêm 2 thẻ
<meta name="description"
và
<meta name="keywords"
Trong ASP.NET 3.5 bạn không thể đưa 2 thẻ này vào trang dễ như thẻ title được
chúng ta có thể làm như sau: trong sự kiện Page_Load bạn khai báo thêm
HtmlMeta metakeywrd = new HtmlMeta(); metakeywrd.Name = "keywords"; metakeywrd.Content = "add keywords here"; HtmlMeta metadesc = new HtmlMeta(); metadesc.Name = "description"; metadesc.Content = "add meta description here"; Page.Header.Controls.Add(metakeywrd); Page.Header.Controls.Add(metadesc);
và khi chạy bạn sẽ thấy chúng ở ngay trên thẻ đóng của thẻ head
Với .Net 4.0 mọi chuyện sẽ đơn giản hơn nhiều
tương tự như Page.Title bạn sẽ có thêm Page.MetaDescription và Page.MetaKeywords
Page.Title = "Page Title here"; Page.MetaDescription = "Meta Description Here"; Page.MetaKeywords = "Meta Keyword here";




