After logging in with facebook account page running in a loop asp.net
<p>Ive just got my login with facebook to work in my application, but ive got strange behavior, after ive logged in, page keep runing in a loop. </p>



Login with Facebook


Hi, (logout)



<p></p>

<pre><code>   // Load the SDK Asynchronously
   (function (d) {
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) { return; }
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
   }(document));

   // Init the SDK upon load
   window.fbAsyncInit = function () {
       FB.init({

           appId: '&lt;%=ConfigurationManager.AppSettings["FacebookClientId"] %&gt;', // App ID
           channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
           status: true, // check login status
           cookie: true, // enable cookies to allow the server to access the session
           xfbml: true  // parse XFBML
       });

       FB.Event.subscribe('auth.statusChange', function (response) {
           if (response.authResponse) {
               // user has auth'd your app and is logged into Facebook
               FB.api('/me', function (me) {
                   if (me.name) {
                       if (response.status === 'connected') {
                           var uid = response.authResponse.userID;
                                           document.getElementById('auth-displayname').innerHTML = me.name;
                                           alert(uid);
                                           var btn = document.getElementById('MainContent_Login1_FBLogin_myButton');
                                           alert(btn);
                                           var label = document.getElementById('MainContent_Login1_FBLogin_FaceBookUid');
                                           label.value = uid;
                                           alert("label value : " + label.value);
                                           btn.click();
                       }
                   }
               })
               document.getElementById('auth-loggedout').style.display = 'none';
               document.getElementById('auth-loggedin').style.display = 'block';
           } else {
               // user has not auth'd your app, or is not logged into Facebook
               document.getElementById('auth-loggedout').style.display = 'block';
               document.getElementById('auth-loggedin').style.display = 'none';
           }
       });
       $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
   }
</code></pre>

<p></p>

<p>So what happends is: </p>

<ul>
<li>I PRess log in with facebook button</li>
<li>Popup window came up</li>
<li>i enter my details</li>
<li>if (response.status === 'connected')  is true and i am actually logged in.</li>
<li><p>after i passed that i throw user id into hiddenfield, and "click" a button which make a server call, so i can check if user already exsists. </p>

<p>right after that page keeps runing in a loop. Is it because of postback i make when i "click" button? </p></li>
</ul>

<p>P.S. if anyone know any other server side solution to make facebook login (with memebership database authentication), let me know, since this solution need alot of tweaking for my needs. </p>
