Xpode.com        Click here to Print this article.

How to put meta tags in content pages in asp.net

For SEO purpose meta tags are very important. If we are using master pages then we need to add meta tag on content pages one by one. To add meta tag on content page, we need to add below code on page load.

protected void Page_Load(object sender, EventArgs e) {
Page.Title = "Title of page";
HtmlMeta tag = new HtmlMeta(); tag.Name = "description"; tag.Content = "description of page"; Header.Controls.Add(tag);

HtmlMeta tagKeyword = new HtmlMeta(); tagKeyword.Name = "keywords"; tagKeyword.Content = "keywords of page"; Header.Controls.Add(tagKeyword ); }

If we want to same meta keyword, meta description in all pages of a master page, then we will enter same in all master page.

We can enter that in html section after title tag and before closing of title tag:

<metaname="Description" content="description of page" />

<metaname="Keywords" content="keywords of page" />

P.S: Master page of content file can be seen in html of content page. In page tag,  MasterPageFile



Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com

Click here to go on website