We help IT Professionals succeed at work.

dynamically setting facebook meta tags in asp.net page

kevinvw1
kevinvw1 asked
on
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.
Comment
Watch Question

Commented:
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" />