使用登录通过microsoft帐户注册用户时出错

时间:2016-01-18 01:12:36

标签: c# asp.net asp.net-mvc asp.net-identity

我使用Microsoft帐户在我的应用程序中配置社交登录。此时,用户可以进行身份​​验证,但是当他按下/ Account / ExternalLoginCallback中的注册按钮时,会出现验证错误(需要UserId)。

Error shown

调试应用程序后,错误显示为此处显示

enter image description here

最后,尽管存在错误,用户仍然保存在数据库中(并且具有用户ID)。

enter image description here

我发现这很奇怪。你知道会发生什么吗?

更新:根据以下评论的要求,以下是一些可能有用的信息。

此图显示用户实际上在抛出异常之前获取了userId。

enter image description here

这是配置代码。老实说,除了clientId和key之外,我没有太大变化。出于显而易见的原因,删除了clientId和Key。

using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;

namespace EmpleoDotNet
{
    public partial class Startup
    {
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication(
                clientId: "[ClientId]",
                clientSecret: "[ClientSecret]");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "BLAH",
            // appSecret: "BLAH");

            //app.UseGoogleAuthentication();
        }
    }
}

0 个答案:

没有答案
相关问题