facebook 的社交登录在 ASP.Net MVC 5 项目中不起作用 [英] Social Login of facebook not working in ASP.Net MVC 5 project

查看:26
本文介绍了facebook 的社交登录在 ASP.Net MVC 5 项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习在我的示例网站中实现 Facebook 社交日志的教程.下面是我做的步骤.

I am going through a tutorial to implement facebook social log in my sample web site. Below are the steps I did.

  1. 将我的本地主机应用程序指向 https 并允许在 VS 中使用假 SSL.
  2. 在 facebook 开发者网站上创建了一个网络应用,并记下了密钥和 ID.
  3. 在 facebook 仪表板的 URL 部分添加了我的应用程序 localhost URL
  4. 我在 ASP.Net MVC-5 项目的 starup.Auth.cs 文件中添加了密钥和 ID.

行为:现在,当我从本地主机 (https) 运行我的应用程序并点击注册然后我看到facebook登录按钮.此外,当我单击该按钮时,一个 facebook 弹出窗口带有示例应用程序"想要访问您的 facebook 数据.到现在为止还挺好.但正如我对它所说的 YES 之后没有任何反应.我被重定向到登录页面.并且 URL 是 https://localhost:44393/Account/Login#_=_

Behavour: Now when I run my application from local host (https) and click Register then I see the facebook sign in button. Also when I click that button a facebook pop up comes with "Sample App" wants to access your facebook data. So far so good. But as I say YES to it nothing happens after that. I get redirected to the log in page. and the URL is https://localhost:44393/Account/Login#_=_

预期行为:对于我在执行上述步骤后遵循的教程,导师屏幕上会出现一条消息,Facebook 已通过身份验证......输入您的电子邮件以继续".像这样的东西.有人可以在这里指导我为什么我没有收到相同的消息以及为什么我无法使用社交登录.我已尝试按照所有步骤操作.

Expected Behaviour: For the tutorial that I am following after doing above steps one message comes on tutors screen as "Facebook has authenticated.... Enter you email to continue". Something like this. Can some one please guide me here why I am not getting same message and why I am not able to use social log in. I have tried to follow all the steps.

教程中的预期屏幕截图

我需要在 Facebook 开发者仪表板中执行任何其他步骤吗?

Is there any other steps I need to do in facebook developer dashboard?

编辑 1:

在我的应用程序的 Facebook 开发者仪表板中的 Facbook 登录选项卡->设置:我看到以下消息.

In the facebook developer dashboard for my app in the Facbook Login Tab->Settings : I see below message.

编辑 2: 我调试并发现 returnURLnull 当我点击 facebook 登录按钮时.

EDIT 2: I debugged and found that returnURL is null when I click on facebook log in button.

   [AllowAnonymous]
        public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
            if (loginInfo == null)
            {
                return RedirectToAction("Login");
            }

            // Sign in the user with this external login provider if the user already has a login
            var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);

推荐答案

好的,经过研究我发现我需要从 nuget 包安装包 Install-Package Microsoft.Owin.Security.Facebook经理.在此之后一切正常.

Ok, After research I found out that I need to install package Install-Package Microsoft.Owin.Security.Facebook from nuget package manager. After this everything worked fine.

这篇关于facebook 的社交登录在 ASP.Net MVC 5 项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆