Adding Meta Tags with Master Pages in Asp.Net

When we are using master pages we dont have any predefine tag or attribute in
page directive which will act as meta tag, Or in simple language we can not add
,meta tags in content pages of a master page. There are two ways to add meta tag

We can add it programatically by using HTMLMeta class, but thats not the correct
way for static pages.

I found very easy solution for adding meta tags

First Add ContentPlaceHolder between head tags in master page like below:

Master page

// master page starting tags

Master Page

// master page other tags

Aspx Page

Now Just after page directive add the content for ContentPlaceholderMetaTags
as below:

// other tags/contents

I think that the reason for the less straight-forward solutions is Visual Studio.
When attempting the above in Visual Studio, the following error is reported:

Error 1 Unrecognized tag prefix or device filter ‘asp’.

This led me, at first, to think that the solution won’t work. Of course,
running the example works just fine and produces the correct HTML which we want.

Happy Coding

Tehmina Qureshi


~ by UTS on May 2, 2009.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: