我在我的网站中通过ASP身份框架使用Google和Facebook身份验证,两个提供商的外部登录在某些时候运行良好但有时它没有,我无法理解问题的来源但是当我重新启动App时,它工作正常。
System.NullReferenceException:未将对象引用设置为对象的实例。 在Microsoft.AspNet.Identity.Owin.SignInManager`2.d__1d.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在SweetNightsIn.Identity.SiteUserManager.d__14.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在SweetNightsIn.Web.Controllers.AccountController.d__3.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 +"
});
如果您需要更多信息,请恢复
答案 0 :(得分:0)
此特定错误是由于Facebook API更改,主要更改涉及API升级为JSON格式的响应