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

查看:267
本文介绍了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。

  1. Pointed my localhost application to https and allowed fake SSL in VS.
  2. Created a web app in facebook developer web site and noted down the secret key and id.
  3. Added my application localhost URL in the URL section of the dashboard in facebook
  4. I added key and id in the starup.Auth.cs file in my ASP.Net MVC-5 project .

Behavour:现在,当我从本地主机(https)和点击注册,然后我看到 facebook登录按钮。此外,当我点击该按钮时,Facebook弹出窗口随附示例应用程序要访问您的Facebook数据。到现在为止还挺好。但是,正如我所说 YES 之后,没有任何事情发生。我被重定向到登录页面。 URL为 https:// localhost:44393 /帐号/登录#_ = _

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:

我的应用程序在Facbook登录选项卡 - >设置中的信息中心:我看到以下消息。

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

编辑2:我调试并发现当我点击Facebook登录按钮时, returnURL null

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天全站免登陆