Dynamically creating Meta Tag from ASP.NET 2.0/1.1

Search Engine optimization is very important to any web site today you can’t get more visitors except search engine optimization.In asp.net site we can also create dynamic meta tags as per our requirement for each page very easily. I will going to show you the two ways of adding meta tags dynamically one for asp.net 2.0 and other for any asp.net version. Lets look first that way and then we will look another way. First you have to add runat=”Server” in your head tag like following.

<head id="Header" runat="server">
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
Then you need to write following code to create metatags dynamically.

protected  void Page_Load(object sender, EventArgs e)

HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content = "DotNetJaps-An asp.net blog";

Now let look at another way of doing this.Here you can to create a static function which will return the string and that string contain the dynamic metatags.

public static string SiteMetaTags()
System.Text.StringBuilder strMetaTag =
new System.Text.StringBuilder(string.Empty);
strMetaTag.AppendFormat(@"<meta content='{0}' name='Keywords'/>",
"DotNetJaps-An asp.net blog");
return strMetaTag.ToString();
Then we have to call that function from asp.net page html like following.

<head >
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
That’s it it will be render as met tag in you asp.net page.Hope this will help you..

Technorati Tags: ,,
Shout it
kick it on DotNetKicks.com


  1. Good post. I am bookmarking your blog.. This free meta tag generator tools provides the easy way of generating title and meta tags for seo onpage optimization. free meta tag generator


Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

Popular posts from this blog

How to create Rest API(Web API) with ASP.NET Core 1.0

Creating PDF with ASP.Net MVC and RazorPDF

Solution: gulp is not recognized as internal or external command- Visual Studio