Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

dynamically setting facebook meta tags in asp.net page

Posted on 2012-08-12
1
Medium Priority
?
2,759 Views
Last Modified: 2012-08-13
I have a web page that let's a user pick a video and then plays the video.
It is similar to YouTube.  
After the user has picked a video they can later reference the video with the URL.
The URL would be something like this - http://www.mywebsite.com/videos?v=123
Where "123" is the id of the video they wish to play.
I am setting meta tag content dynamically on page load using asp.net.
If I view the page -  http://www.mywebsite.com/videos?v=123 I can see that the facebook metatags have been properly rendered.
All the proper facebook opengraph tags are there including "og:image" and that tag resolves to a jpg image on my server.
When I paste the above link in to facebook it does not pull the image in to the facebook post.
However if I hard-code the og:image meta tag in to the page then the preview image will display in the facebook post.

My question is, do the dynamic meta tags actually get rendered when facebook reads the URL?  I currently have the code in the page_load event of the asp.net page.  

Any help would be greatly appreciated.

Thanks,  Kevin.
0
Comment
Question by:kevinvw1
1 Comment
 

Accepted Solution

by:
kevinvw1 earned 0 total points
ID: 38289529
I figured out the issue.  
Found a reference here - http://stackoverflow.com/questions/7554749/asp-net-change-facebook-og-properties-from-content-page

Facebook was reading the tags just fine.  The tags were not formed quite right.  I was using HTMLMeta and adding tags like this -

HtmlMeta _ogDescription = new HtmlMeta();
_ogDescription.Name = "og:description";
_ogDescription.Content = "";
((Control)Header).Controls.Add(_ogDescription);

which gives me - <meta name="og:description" content="This is a test" />
 
What I needed to do was set the meta tag as "property" not "name" like this -

_ogDescription.Attributes.Add("property", "og:description");
_ogDescription.Content = "";
((Control)Header).Controls.Add(_ogDescription);

which gives me - <meta property="og:description" content="This is a test" />
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 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