使用Owin登录Facebook弹出窗口



我使用MVC和Owin外部登录Facebook。

Owin不会以弹出方式打开facebook登录。它将页面重定向到facebook。

我知道有一个选项,使facebook登录打开弹出窗口。我们需要在URL中添加"&dialog=popup"。

我对OWIN没有这个选择。

有办法做到这一点吗?

我也遇到了同样的问题。在阅读了来源后,我找到了一个解决方案:

基本上:你需要继续为Facebook创建一个身份验证提供商。因此,创建一个继承自FacebookAuthenticationProvider的类。在这个类中,重写"ApplyRedirect"方法。让它看起来像:

public override void ApplyRedirect(FacebookApplyRedirectContext context)
{
    context.Response.Redirect(context.RedirectUri + "&display=popup");
}

现在只需将这个类与您的配置连接起来,如下所示:

app.UseFacebookAuthentication(new FacebookAuthenticationOptions
{
    Provider = new **<the name of the class that you created>**()
    // the rest of your configuration such as app ID and secret
});

应该就是这样!

最新更新