Home > Asp.net > Set meta tag in asp.net programmaticaly for seo friendly websites

Set meta tag in asp.net programmaticaly for seo friendly websites


When you are developing SEO friendly websites, the first basic thing for seo is meta tags, as all search engines are looking for these meta tags while querying the database. Here we will allow the user to set the “keywords” and “description” (the two parts of meta tag)and then set the meta tag programmatically.

This is how meta tags are set dynamically:

HtmlMeta mKey = new HtmlMeta();
mKey.Name = “keywords”;
mKey.Content = “home, blog”;
this.Page.Header.Controls.Add(mKey);

HtmlMeta mdesc = new HtmlMeta();
mdesc.Name = “description”;
mdesc.Content =”home page”;
this.Page.Header.Controls.Add(mdesc);

after doing that you can view in the “View Source” of the page you have set meta tags under the head section.

<meta name="keywords" content="home,blog" />
<meta name="description" content="home page" />
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: