|| Published on :
Tuesday, July 29, 2014 || Views:
ASP.NET Meta tags SEO ASP.NET Meta Keywords Meta Description SEO friendly websites
Search Engine Optimization or SEO helps a website to get generic traffic from internet and traffic is very important for a website to retain in the market and when we are developing Search Engine Optimization or SEO friendly ASP.NET Websites, the first and important basic thing for Search Engine Optimization or SEO is the META Tags(like Keywords, Title, Description), while generally all Serach Engine like Google.com, Yahoo.com etc are looking for these META Tags(like Keywords, Title, Description) while making querying the Databases.
In last articles, We have learned How to validate or check whether checkbox is checked or not using ASP.NET and jQuery with example. and How can we call a C# Method from ASPX Page or Code Behind page and now we will learn how to Set meta tag in ASP.NET programmaticaly for creating SEO friendly websites.
Here we will set the SEO MetaTags "Keywords" and "Description" from the CodeBehind of the ASPX page. Here we are using ASP.NET as main core technology
So lets start the example:
Step 1: Create a ASP.Net Empty website by starting Visual Studio 2013 or any other Visual Studio Edition. You can download the free edition from here and also get other details regarding Visual Studio
Step 2: Create a new Web form page, by right clicking on solution explorer > Add new Items > Web Form and name it as you like, mine is "SetMetaTags.aspx"
Step 3: In the Code Behing of the web form you just added, write the following codes. In the we are creating a two instances of HTMLMETA class and setting their name and content property and finally add that to the Page header Control
public partial class SetMetaTags : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
HtmlMeta mKey = new HtmlMeta();
mKey.Name = "";
mKey.Content = "SourceCodehub, free programming articles, ASP.net Codes ";
HtmlMeta mdesc = new HtmlMeta();
mdesc.Name = "description";
mdesc.Content ="Here you will get free asp.net source codes";
Output will be like this....
So In this article we learn how we can Set meta tag in ASP.NET programmaticaly for creating seo friendly websites.
Download Source Codes