Powered by Blogger.

Sunday, February 16, 2014

Adding meta tags to aspx pages in asp.net



In this article we will discuss about how to add meta tags and meta description to .aspx page in an Asp.Net web site. Meta tags and descriptions are very much useful in the context of search engine. So it is necessary to give meta tags and meta descriptions to web sites.

There are at least 3 ways we can add meta tags and description to an .aspx page.

1. Add in the page directive:
We can add meta tags and description to the page directive of an .aspx page like below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MetaTagTest.aspx.cs" Inherits="MetaTagTest"  MetaDescription="A SharePoint and Asp.Net web site" MetaKeywords="SharePoint,Asp.Net,C#.Net,SQL Server" %>

Here MetaDescription, MetaKeywords are the tags to whom we can set the description and tag respectively.

2. Inside head section:
We can add Meta tags and description inside the <head> </head> section of an .aspx page like below:

<meta name="description" content="A SharePoint and Asp.Net web site" />
<meta name="keywords" content="SharePoint,Asp.Net,C#.Net,SQL Server" />

3. Through .aspx.cs code:
Through code we can also add meta tag and meta description to a page like below:

 protected void Page_Load(object sender, EventArgs e)
    {
        Page.MetaDescription = "A SharePoint and Asp.Net web site";
        Page.MetaKeywords = "SharePoint,Asp.Net,C#.Net,SQL Server";
    }



0 comments

Post a Comment