Pass image, summary, URL to Facebook share button in ASP.NET MVC

1.6k views Asked by At

I'm trying to put Facebook "Share" buttons on various elements on a one-page Bootstrap ASP.NET MVC page. When each button is clicked, it would display a different image, summary, and URL for that element on the page. The URL will send the user to a specific tag on the page, or display a blog post; so, even though this is a single-page design, the URL, summary, images will be different for different elements.

Facebook no longer supports the old method of passing that information on the URL to its sharer.php, but uses the new Open Graph og:parametername meta tags to fetch the necessary information. However, as I require a different image, summary, etc., for each "Share" button, this og:... technique outlined in this SO answer won't work.

I've found some documentation on this site about using the Facebook SDK for Web Developers, but its examples aren't addressing what I'm trying to do. Is it even possible to do what I'm describing?

Thanks.

1

There are 1 answers

4
Kaizen Programmer On BEST ANSWER

You'll have to create a redirecting page that will hold all the correct FB og: fields.

You can pass all the values into a generic view to setup the og: fields, then in the body of the view use Javascript to redirect them to the content you really want them to see.

<script> location.href = 'http://example.com/the_real_page'; </script>