bjorkn
asked on
update meta tag - stuck in cache
Hi, I'm trying to updating the meta tag before I share my page on facebook
I'm having some problems, because the meta tag seems to get stuck in the cache or something, or it seems to behave rather randomly, so either I can't change it or that after I've managed to change it ones, I can't change it again.
I'v included a code of a very small program that does nothing else than change the metatag of a page and share it on facebook. Also a picture of the sharing which shows that the original metatag is used and not the change I put in.
I'm having some problems, because the meta tag seems to get stuck in the cache or something, or it seems to behave rather randomly, so either I can't change it or that after I've managed to change it ones, I can't change it again.
I'v included a code of a very small program that does nothing else than change the metatag of a page and share it on facebook. Also a picture of the sharing which shows that the original metatag is used and not the change I put in.
In the master page I define the meta tags:
<meta name="title" content="This is the Title" />
<meta name="description" content="This is a short summary of the page." />
In sharefacebook.aspx I put the label:
<asp:Label ID="labelSteps_1_2" runat="server" Text=""></asp:Label>
and in sharefacebook.aspx.cs I put the facebook properties on the label, and I change the content of the meta tags
protected void Page_Load(object sender, EventArgs e)
{
labelSteps_1_2.Text = "<a name=\"fb_share\" type=\"button\"></a>" +
"<script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " + "type=\"text/javascript\" > </script>";
HtmlMeta tag = new HtmlMeta();
tag.Name = "title";
tag.Content = "Title test";
Page.Header.Controls.Add(tag);
HtmlMeta tag1 = new HtmlMeta();
tag1.Name = "description";
tag1.Content = "description test";
Page.Header.Controls.Add(tag1);
}
Please find Meta Tag in Header using Page.Header object and replace the tag value.
ASKER
Thank you, it's a good idea, but do you know how I can acess the metaTitle property from a content page, since the meta definition is in the master page
and the metaTitle.Attributes("cont ent") = "Title test";
is in a content page
regards, Bjork
and the metaTitle.Attributes("cont
is in a content page
regards, Bjork
ASKER
PatelAlpesh:
I'm not sure what you mean in your answer
Isn't that what I'm doing by this:
Page.Header.Controls.Add(t ag);
I'm not sure what you mean in your answer
Isn't that what I'm doing by this:
Page.Header.Controls.Add(t
ok to get the master page control do this
((HtmlMeta)Master.FindCont rol("metaT itle")).Co ntent = "Title test";
((HtmlMeta)Master.FindCont
ASKER
no it didn't work
I really thought this would work,
I'm wondering if the master page rewrite the content of the meta tag after I change it in the content file, this is very strange
I really thought this would work,
I'm wondering if the master page rewrite the content of the meta tag after I change it in the content file, this is very strange
ASKER
I see now that the metatag seems to update perfectly.
It just when I'm sharing it on facebook where it seems to get lost or maybe facebook is using a cache which isn't updated very often....
It just when I'm sharing it on facebook where it seems to get lost or maybe facebook is using a cache which isn't updated very often....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<meta name="title" content="This is the Title" id="metaTitle" runat="server" />
then this
HtmlMeta tag = new HtmlMeta();
tag.Name = "title";
tag.Content = "Title test";
Page.Header.Controls.Add(t
becomes this
metaTitle.Attributes("cont