Facebook like button not showing

I am trying to add the facebook like button to an ASP.NET page. I have generated the code with the Get Like Button Code Widget and copied it into my master page. The like button works fine most of the time but for some random pages it doesn't. I have checked for javascript errors using the developer tools javascript console in Chrome but there doesn't seem to be any (I get the same problem in FF and IE as well).

Even more bizarly I can browse to a url such as mysite.com/category/12345/some-descriptive-name and see the problem. But knock a couple of letters off the end of the url (e.g. mysite.com/category/12345/some-descriptive-na) and the problem dissapears [I am using url redirection so as long as the id is the same, the same page is served up].

My best idea was that I was hitting some maximum url length, but that doesn't seem to be the problem as simply changing the Id in the url above works as expected as well.

I have tried both the HTML5 and the XBFML versions of the like button, both with the same problem.

The only other thing I could come up with is generating an appId in the hope that that would make it more reliable.

I am unable to point you to a publicly available site at this time, but the code is below:

...
<body class="clearfix">
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
...
<div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-font="segoe ui"></div>

Answers


This SO answer pointed me in the right direction. Using that tool on a link that worked actually caused the like button to stop working on that link further. Looking deeper into the results, there was a redirect section and FB was being redirected to my login page.

This problem was identified on a test site which is locked down. Removing forms authentication temporarily and then running the link through lint resolved the problem.


Need Your Help

VIM: How to access the redo-register

python vim autocomplete refactoring rename

As a secondary task to a Python auto-completion (https://github.com/davidhalter/jedi), I'm writing a VIM plugin with the ability to do renaming (refactoring).

MySQL Query: Get new customers in the month

mysql sql

I have millions of records in a table with following columns: