Method One
if (! IsPostBack)
{
Page title
Page.title = "My site title";//the page head tag must be set to the server control mode, that is
Description page description
Htmlmeta desc = new Htmlmeta ();
Desc. Name = "Description";
Desc. Content = "Description of my Site";
PAGE.HEADER.CONTROLS.ADD (DESC);
Keyword page keywords
Htmlmeta keywords = new Htmlmeta ();
Keywords. Name = "keywords";
Keywords. Content = "My Site keywords";
PAGE.HEADER.CONTROLS.ADD (keywords);
}
Method two < non-master pages under >
In the development of Web pages for search engine optimization, add the page title keyword description is one of the most commonly used methods. The method code for the ASP. NET is as follows:
public void Seo_head (string title, string keyword, string description)
{
Page.title = Title + "-my blog-";
Htmlmeta metakeywords = new Htmlmeta ();
Htmlmeta metadescription = new Htmlmeta ();
Metakeywords.name = "Keywords";
metakeywords.content = keyword;
Metadescription.name = "description";
metadescription.content = description;
HEADER1.CONTROLS.ADD (metakeywords);
HEADER1.CONTROLS.ADD (metadescription);//header1 is the head ID.
}
---------Delete the title tag of the content page if there is no master page----------
Three other
The recommended simple practices are as follows:
protected void Page_Load (object sender, EventArgs e)
{
Page Title
Page.title = "This is a Title and Meta test page.";
Encode/content type
Htmlmeta encode = new Htmlmeta ();
Encode. HTTPEQUIV = "Content-type";
Encode. Content = "text/html; Charset=utf-8 ";
PAGE.HEADER.CONTROLS.ADD (encode);
Language
Htmlmeta lang = new Htmlmeta ();
Lang. HTTPEQUIV = "Content-language";
Lang. Content = "ZH-CN";
Page.Header.Controls.Add (lang);
Description
Htmlmeta desc = new Htmlmeta ();
Desc. Name = "Description";
Desc. Content = "Test the meta controls";
PAGE.HEADER.CONTROLS.ADD (DESC);
Keyword
Htmlmeta keywords = new Htmlmeta ();
Keywords. Name = "keywords";
Keywords. Content = "Title,meta,test,page";
PAGE.HEADER.CONTROLS.ADD (keywords);
Link/css
Htmllink Csslink = new Htmllink ();
Csslink.href = "Masterpage.css";
CSSLINK.ATTRIBUTES.ADD ("rel", "stylesheet");
CSSLINK.ATTRIBUTES.ADD ("type", "text/css");
PAGE.HEADER.CONTROLS.ADD (Csslink);
}
(ext.) ASP. Dynamic Settings Header title Title Keyword Keywords Description descrtptions