Authentication 中间件中ASP标识的外部身份验证失败

Authentication 中间件中ASP标识的外部身份验证失败,authentication,asp.net-identity,owin,Authentication,Asp.net Identity,Owin,我在我的网站上通过ASP身份框架使用Google和Facebook身份验证,两个提供商的外部登录在某些时候都可以正常工作,但有时不行,我不知道问题出在哪里,但在我重新启动应用程序时可以正常工作 System.NullReferenceException:对象引用未设置为对象的实例。 在Microsoft.AspNet.Identity.Owin.SignInManager`2.d_u1d.MoveNext()中 ---来自引发异常的上一个位置的堆栈结束跟踪--- at System.Runtim

我在我的网站上通过ASP身份框架使用Google和Facebook身份验证,两个提供商的外部登录在某些时候都可以正常工作,但有时不行,我不知道问题出在哪里,但在我重新启动应用程序时可以正常工作

System.NullReferenceException:对象引用未设置为对象的实例。 在Microsoft.AspNet.Identity.Owin.SignInManager`2.d_u1d.MoveNext()中 ---来自引发异常的上一个位置的堆栈结束跟踪--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中 在SweetNightsIn.Identity.SiteUserManager.d_u14.MoveNext()中 ---来自引发异常的上一个位置的堆栈结束跟踪--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中 在SweetNightsIn.Web.Controllers.AccountController.d_u3.MoveNext()中

OWIN startup.cs看起来像这样

// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        app.CreatePerOwinContext(IdentityDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString(AppConstants.LoginPath)

        });

        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

        FacebookAuthenticationOptions facebookOptions = new FacebookAuthenticationOptions()
        {
            AppId = ConfigurationManager.AppSettings["FacebookAppId"],
            AppSecret = ConfigurationManager.AppSettings["FacebookAppSecret"],
            UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email",
            BackchannelHttpHandler = new FacebookBackChannelHandler()
        };

        facebookOptions.Scope.Add("email");

        app.UseFacebookAuthentication(facebookOptions);

        app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
        {
            ClientId = ConfigurationManager.AppSettings["GoogleAppId"],
            ClientSecret = ConfigurationManager.AppSettings["GoogleAppSecret"],
            Caption = "Google +"
        });
//有关如何配置应用程序的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=316888
app.CreatePerOwinContext(IdentityDbContext.Create);
app.CreatePerOwinContext(ApplicationUserManager.Create);
app.CreatePerOwinContext(ApplicationSignInManager.Create);
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(AppConstants.LoginPath)
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
FacebookAuthenticationOptions facebookOptions=新建FacebookAuthenticationOptions()
{
AppId=ConfigurationManager.AppSettings[“FacebookAppId”],
AppSecret=ConfigurationManager.AppSettings[“FacebookAppSecret”],
UserInformationEndpoint=”https://graph.facebook.com/v2.8/me?fields=id,姓名,电邮“,
BackchannelHttpHandler=新FacebookBackChannelHandler()
};
facebookOptions.Scope.Add(“电子邮件”);
app.UseFacebookAuthentication(facebookOptions);
app.UseGoogleAuthentication(新的GoogleOAuth2AuthenticationOptions()
{
ClientId=ConfigurationManager.AppSettings[“GoogleAppId”],
ClientSecret=ConfigurationManager.AppSettings[“GoogleAppSecret”],
Caption=“谷歌+”
});

如果您需要更多信息,请回复此特定错误是由于Facebook API更改引起的,主要更改涉及将API的响应升级为JSON格式