Thursday, July 8, 2010

Metadata feature of .net 4.0

In order to add the metadata dynamically in .net 4.0 you could do following:

Suppose you need to get the state from the URL then you do :
string stateid=Page.RouteData.Values["state"] as string;
new state id should be in stateid.

Now add the metadata
Page.MetaDescription="A List of states in "+stateid;
Also we can set keywords with Page.MetaKeywards

And this would include the meatdata in the View Source section dynamically.

No comments:

Post a Comment