Subscribe to the ASP.NET Robot RSS Feed

ASP.NET Title Tag and Meta Tags





Meta tags and title tag used to provide some basic information about a web page like page title, page description, page keywords and more.
I recommend don’t use more than 65 Characters (Including Spaces) for a Page Title Tag, for the meta description tag don’t use more than 150 Characters (Including Spaces) and for meta keywords tag Pick the 10 or 15 terms that most accurately describe the content of the page. But remember that today most of the search engines ignoring the Meta keywords tag.


This tags you can set in the head section of the page like this:

<head runat="server">
    <title>Your Page Title</title>
    <meta name="description" content="Your Page Description" />
    <meta name="keywords" content="Your Page Keywords" />
</head>



   
     

Define Title Tag and Meta Tags in ASP.NET 4.0

  

The following code demonstrates how you can set this properties programmatically from code behind in ASP.NET framework 4.0 within Page_Load() event handler

protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "Your Page Title";
        Page.MetaDescription = "Your Page Description";
        Page.MetaKeywords = "Your Page Keywords";
    }

Or you can declare these tags in the @Page directive at the top of .aspx pages like this:

<%@ Page Title="Your Page Title" 
         MetaDescription="Your Page Description" 
         MetaKeywords="Your Page Keywords" 
         Language="C#" 
         AutoEventWireup="true" 
         CodeFile="Default.aspx.cs" 
         Inherits="_Default"  %>



    
    

Declare Title Tag and Meta Tags in ASP.NET 3.5 and Blow

 

The following code demonstrates how you can declare this properties programmatically from code behind in ASP.NET framework 3.5 and blow within Page_Load() event handler

protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "Your Page Title";

        HtmlMeta metaDescription = new HtmlMeta();
        metaDescription.Name = "description";
        metaDescription.Content = "Your Page Description";
        Page.Header.Controls.Add(metaDescription);

        HtmlMeta metaKeywords = new HtmlMeta();
        metaKeywords.Name = "keywords";
        metaKeywords.Content = "Your Page Keywords";
        Page.Header.Controls.Add(metaKeywords);
    }

Add New Comment:

 
 
 
 
 
Gravatar

Viagra

Pero king jailed for three years Mairena del Aljarafe.

Gravatar

Line

Viagra vs I take Cialis regardless on both empty and full stomachs and it works for me.

Gravatar

Female_viagra

Very nice,

Gravatar

Viagra

Good site,

Gravatar

Internet

s a month, if you can get a prescription for those amounts.

Gravatar

Tadacip

Anadia daily Ovar viagra medicamento Vale de Cambra v is for viagra Ovar cialis o que ?

Gravatar

Pharmd951

Hello! dgdekkk interesting dgdekkk site! I'm really like it! Very, very dgdekkk good!

Gravatar

Buy_viagra

Society piu potente noting all for arrived test backs andhow hours hospital suspicion.

Gravatar

Lolakaie

Good morning, thank you for this article. Very helpful indeed. More power and good luck.

Gravatar

SEO Australia

we have to know all the basics

Gravatar

Amit

how to check meta tag are working or not

Gravatar

Amit

how to check meta tag are working or not

Gravatar

Shiv

Thanx buddy its working fine now

Gravatar

Mahan Developer

Yo Yo Developer

Gravatar

Charan

This is what am looking for .. my title and description showing duplicate now after set the title and description through code behind its working fine.. no errors thanks for sharing

Gravatar

Dfdfsd

fdvd

Gravatar

Cdcgfdgdfgd

aaaaaaaaaaaaaaaaaaaaaaaaavvvvvvvvvvvvvvvvvvvvvvvvvvvvvdffffffffffffffffffffffffffffffffffffffffffffffffff

Gravatar

Abc

fgdff

Gravatar

Scott taylor

sir, I configured your code.. and finally I m getting result through your web.
Thanks & regards
www.quikrloan.us

Gravatar

Scott taylor

sir, I configured your code.. and finally I m getting result through your web.
Thanks & regards
www.quikrloan.us

Gravatar

D

df

Gravatar

Outsource seo

Hi. I'm optimizing my clients website in aspx language. Is this the same as aspx language? I'm getting a hard time finding its head tag. Thanks.

Gravatar

Jkl

jklj

Gravatar

Test

test

Gravatar

Test

test

Gravatar

Sfdfd

fgdgfdg

Gravatar

Camps breakers

Thãn for this information it is very very important :)

Gravatar

Ds

sf

Gravatar

Techhowtips

really nice info it helped me a lot

Gravatar

Evandro

Great :)

Gravatar

JNet

Nice way to add meta tags. But one problem ? How search engine will search for this keywords, as all keywords & contents are stored in database ? For example, if I had a website whereby i m flashing different text contents by fetching them from database. If user wants to search via google ad sense which is provided in my site, how will it search those keywords from my database and display the results from my website ? Is there any solution to this ?

Facebook del.icio.us FriendFeed Digg it Google Buzz Linked in MySpace Reddit Stumbleupon Twitter Technorati