Geeks With Blogs
mikedopp Geekswithblogs (edition)

So here is a question why would you want to add your Meta Tags via code? Kinda silly right? Cause if you were a great developer you probably have a whole list of meta tags you have created for your portfolio of web sites right?

Well if you are the developer who has those templates you most likely will stop reading here and think this mikedopp character is kinda wierd or is one of those "because you can" type people. I know I am adding much too much fluff to this whole entry and spending too much time with words so here is the code to add meta tags to your on load event of either your master pages or just to that web site that you need to get out the door tonight.

private void AddMetaTags()
    {
        if (this.Page != null)
        {
            base.Title = Server.HtmlEncode(this.Page.Title);
            base.AddMetaTag("keywords", Server.HtmlEncode(this.Page.Keywords));
            base.AddMetaTag("description", Server.HtmlEncode(this.Page.Description));
        }
    }

As an added bonus you could just create a large list of meta tags in your web.config file or another dot config file within your application or site that is just read into the site on_load.

There is also the possibility of having a large SQL/XML table that holds all your tags and is read in based upon the name of the page and content that is requested.

#Region ---This is where I go on a rant--- Feel free to get some popcorn and a diet mountain dew---

However since the only search provider that reads meta tags is MSN Live search and not google as I have been told (I still don't believe that).

There is no point to this post. So go ahead an move on to the next post on how to put all your keywords in a database and read them into the page content based on the same factors (for Google of course).

#EndRegion---End of rant

 

Posted on Sunday, March 30, 2008 7:49 AM | Back to top


Comments on this post: Adding Meta Tags via Code - C# in ASP.NET

# re: Adding Meta Tags via Code - C# in ASP.NET
Requesting Gravatar...
Hi, thanks for this post. this is a very nice code to add metatags. Description and Keywords are realy important as they are read by search engine while searching a website. meta-description is visible to the visitor. So these metatags should be written very effectively. Some techniques i read from http://www.seositecheckup.com. To write effective metatags these are very nice tips::
http://www.seositecheckup.com/articles/5
Left by David on Dec 30, 2009 5:26 AM

Your comment:
 (will show your gravatar)


Copyright © mikedopp | Powered by: GeeksWithBlogs.net