简体   繁体   English

asp.net Web应用程序中的Facebook注销按钮

[英]Facebook Logout button in asp.net web application

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. 我正在尝试创建一个asp.net Web应用程序,当用户通过我的应用程序使用Facebook登录时,该用户的朋友将显示在应用程序中。

Now i want to create a Facebook Logout button so that user can log out also. 现在,我想创建一个Facebook注销按钮,以便用户也可以注销。 I tried one code 我尝试了一个代码

HTML: HTML:

<asp:ImageButton ID="imgLogout" runat="server" OnClientClick="FB_Logout()"     ImageUrl="~/logout.jpg"/>

Script: 脚本:

<script type="text/javascript">
function FB_Logout() {

alert('Are you sure?')
FB.Connect.logoutAndRedirect("http://localhost:2708/List.aspx");

}

</script>

it was working fine. 工作正常。 But now user can not logout. 但是现在用户无法注销。 Clicking on Facebook Login Button directly opens the already logged in user. 单击Facebook登录按钮直接打开已登录的用户。

I think you might be using an old SDK. 我认为您可能正在使用旧的SDK。

According to the recent JS SDK you would use FB.logout 根据最近的JS SDK,您将使用FB.logout

as in: https://developers.facebook.com/docs/reference/javascript/FB.logout/ 如: https : //developers.facebook.com/docs/reference/javascript/FB.logout/

Also because you want to redirect you could either redirect straight after the logout code with 同样因为您要重定向,您可以在注销代码后直接重定向

window.location='';

or hook on the logout event in Facebook and do the redirect. 或挂接到Facebook中的注销事件并进行重定向。 eg 例如

 FB.Event.subscribe("auth.logout", function() {window.location = '/users/logout'});
{$callback}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM