Integrate FB javascript API to your app to implement FB connect


I am going to demonstrate how you can use FB Javascript API to implement Facebook connect applications, as the facebook toolkit for .net is extremely unstable. You have to integrate the below code in your app.


1)You need a channel.html file , content of that file is only this tag nothing else not even any standard html tags
<script src=””></script&gt;
2) Top of the page where you are using this code replace your html tag by this tag (required for consistency across browsers)
<html xmlns=”; xmlns:fb=””&gt;


<fb:login-button perms="email,user_photos"
size="large" length="long">Login with Facebook</fb:login-button>
<div style="display: none;">
<asp:Button ID="fbRegister" runat="server" Text="Ok"
onclick="fbRegister_Click"  />

<input id="hidEmail" type="hidden"runat="server" />
<input id="hidFirstName" type="hidden"runat="server" />
<input id="hidLastName" type="hidden"runat="server" />
<input id="hidUID" type="hidden"runat="server" />
<div id="fb-root">
<script src=""
<script type="text/javascript">
FB.init({ appId: 'YOUR_APP_ID', status: true, cookie: true,
xfbml: true, channelUrl: "channel.html" });
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
FB.api('/me', function(response) {
    $("#<%=hidEmail.ClientID %>").val(;
    $("#<%=hidFirstName.ClientID %>").val(response.first_name);
    $("#<%=hidLastName.ClientID %>").val(response.last_name);
    $("#<%=hidUID.ClientID %>").val(;
    $("#<%= fbRegister.ClientID %>").click();
    } else {
      // The user has logged out, and the cookie has been cleared


function LoginWithFB() {
       $("#<%= fbRegister.ClientID %>").click();

Replace YOUR_APP_ID with your application id that you get during application registration with facebook. You can download sample code from here[^]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s