Solved

update meta tag - stuck in cache

Posted on 2010-11-24
8
920 Views
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=\"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);



      

           }

Open in new window

0
Comment
Question by:bjorkn
8 Comments
 
LVL 6

Expert Comment

by:ajb2222
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";
        Page.Header.Controls.Add(tag);


becomes this

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

Expert Comment

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

Author Comment

by:bjorkn
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
0
 

Author Comment

by:bjorkn
ID: 34205188
PatelAlpesh:

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

Page.Header.Controls.Add(tag);

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

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

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

Author Comment

by:bjorkn
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

0
 

Author Comment

by:bjorkn
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....
0
 
LVL 6

Accepted Solution

by:
johndoeherty 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.

Greets
JD
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now