asp.net Web应用程序中的Facebook注销按钮
我正在尝试创建一个asp.net Web应用程序,当用户通过我的应用程序登录Facebook时,该用户的朋友将显示在应用程序中.
I am trying to create an asp.net web application, in which when user logins with Facebook through my application, the friends of that user will be displayed in the application.
现在,我想创建一个Facebook注销按钮,以便用户也可以注销.我尝试了一个代码
Now i want to create a Facebook Logout button so that user can log out also. I tried one code
HTML:
<asp:ImageButton ID="imgLogout" runat="server" OnClientClick="FB_Logout()" ImageUrl="~/logout.jpg"/>
脚本:
<script type="text/javascript">
function FB_Logout() {
alert('Are you sure?')
FB.Connect.logoutAndRedirect("http://localhost:2708/List.aspx");
}
</script>
工作正常.但是现在用户无法注销.单击Facebook登录按钮直接打开已经登录的用户.
it was working fine. But now user can not logout. Clicking on Facebook Login Button directly opens the already logged in user.
我认为您可能正在使用旧的SDK.
I think you might be using an old SDK.
根据最新的JS SDK,您将使用FB.logout
According to the recent JS SDK you would use FB.logout
如下所示: https://developers.facebook.com/docs/参考/javascript/FB.logout/
此外,因为您要重定向,您可以使用以下注销代码后直接重定向
Also because you want to redirect you could either redirect straight after the logout code with
window.location='';
或挂接到Facebook中的注销事件,然后执行重定向.例如
or hook on the logout event in Facebook and do the redirect. e.g.
FB.Event.subscribe("auth.logout", function() {window.location = '/users/logout'});
{$callback}