update meta tag - stuck in cache

Posted on 2010-11-24
Last Modified: 2012-08-13
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.  sample from facebook share
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=\"\" " +  "type=\"text/javascript\"  >  </script>";

        HtmlMeta tag = new HtmlMeta();
        tag.Name = "title";
        tag.Content = "Title test";

        HtmlMeta tag1 = new HtmlMeta();
        tag1.Name = "description";
        tag1.Content = "description test";


Open in new window

Question by:bjorkn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 34205091
change the meta tag to look like this

         <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";

becomes this

       metaTitle.Attributes("content") = "Title test";
LVL 21

Expert Comment

by:Alpesh Patel
ID: 34205139
Please find Meta Tag in Header using Page.Header object and replace the tag value.

Author Comment

ID: 34205142
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("content") = "Title test";

is in a content page

regards,  Bjork
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


Author Comment

ID: 34205188

I'm not sure what you  mean in your answer
Isn't that what I'm doing by this:



Expert Comment

ID: 34205592
ok to get the master page control do this

((HtmlMeta)Master.FindControl("metaTitle")).Content =  "Title test";

Author Comment

ID: 34206708
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


Author Comment

ID: 34206848
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....

Accepted Solution

Mike D earned 500 total points
ID: 34211831
You have to use the Facebook 'URL Linter' (just google it) as Admin of the App. That will refresh the Facebook Cache.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question