Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 4523 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > ASP.NET 4.0 Features - MetaDescription and MetaKeywords

ASP.NET 4.0 Features - MetaDescription and MetaKeywords

Article posted by Abhijit Jana on 3/1/2010 | Views: 4777 | Category: ASP.NET | Level: Beginner red flag


ASP.NET 4.0, came up with two new properties inside Page Class, those are MetaDescription and MetaKeyWord. This has been introduce because of make web application Search Engine Friendly. Search Engine looks for Meta tag of our web page to get the details of page contents. In ASP.NET 4.0, we can add these two properties with page class in Code behind or in Page Directives.

Introduction
ASP.NET 4.0, came up with two new properties inside Page Class, those are MetaDescription and MetaKeyWord. This has been introduce because of make web application Search Engine Friendly.  Search Engine looks for Meta tag of our web page to get the details of page contents.  In ASP.NET 4.0, we can add these two properties with page class in Code behind or in Page Directives.

If you want to find out the definition of these two properties, Right Click on Page Class and Click on Goto Definition. This will show you the Meta data information of Page Class as shown in below picture.


Fig:Page Class with MetaDescription and MetaKeyWords Properies
How to use ?


If we set MetaDescription and MetaKeywords either from Code behind or using Page Directive in aspx page, both will be render as “meta” tag in html code.
Let have a look, how we can set these two properties from code behind,

protected void Page_Load(object sender, EventArgs e)

{

Page.MetaKeywords = "ASP.NET 4.0, .NET 4.0";

Page.MetaDescription = "ASP.NET 4.0 Information";

}



Fig: Set MetaKeywords and MetaDescription Properties using Codebehind

Now, If I run the application and check the HTML rendered content we will found the following code,

<head>

<meta content="ASP.NET 4.0 Information" name="description" />

<meta content="ASP.NET 4.0, .NET 4.0" name="keywords" />

</head>

Similarly we can also add MetaKeywords and MetaDescription Properties  in Page Directive Itself. 


But the HTML output will be same for both the case.

Fig: HTML Rendered content of MetaKeywords and MetaDescription

Conclusion
The main objective of MetaKeywords and MetaDescription proerties to make your web application SEO friendly. In ASP.NET 2.0, HtmlMeta used to do the same, but in ASP.NET 4.0 make these thing  very simple as we can easily add using Page Class.
Please share your feedback and suggestion to improve this article.

Reference :
ASP.NET 4.0 Features

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Abhijit Jana

Experience:3 year(s)
Home page:http://abhijitjana.net
Member since:Wednesday, December 24, 2008
Level:Bronze
Status: [Member] [MVP]
Biography:He has done Master Degree in Computer Application and currently working as a Sr. S/W Developer in a US based MNC and having more than 3 years exp. He has worked with all the .NET framework and good exposer in Web and Windows based development using Microsoft Technology . Currently he working with C# 3.5, ASP.NET 3.5, Enterprise Library 4.1 and SDL Tridion also Exploring VS 2010 with .NET 4.0.
 Responses
Posted by: Sashidhar.ssd | Posted on: 01 Mar 2010 07:11:41 AM

Nice One as always..!

>> Write Response - Respond to this post and get points
Related Posts

When we consume business objects in UI the logic can become pretty complex. Activities like setting the business object value, getting the object value and setting the user interface from the object value. We can minimize the complexity of UI interaction with business object using mediator pattern.

Listing all the steps to show how to configure the SQL Server so that our .Net application can store and retrieve the Session values in and from SQL server.

Security is one of the major aspects in terms of a web application. Security can be implemented using different methods in a web application. One of the main components, which required high security, is the configuration files, where we will define the configurations. In this document, we will discuss about the simple way to protect the web.config entries.

To select multiple records from the GridView and retrieve selected records, we can follow this approach.

You might have came across a situation where you need to pass a value from your .aspx page to the user control (.ascx). This is possible in several ways including storing values into session or database and again retrieving at the user controls. However, the easiest and optimized way is to create a properties of the user control and set it into the .aspx page and access it from the user control.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 7:51:28 AM