C#Owin登录在生产系统上生成identity = null

我有一个asp.net MVC 5 web项目,它在我的开发系统上运行良好。 但出于某种原因,在我的生产系统上部署解决方案后,使用Microsoft Owin和Facebook的登录就会停止工作。

回调总是检索…. error = access_denied作为参数,我追溯到owin为我的身份返回null的事实。 有什么线索在这里发生什么?

UPDATE

我在我的Owin代码中实现了log4net,并且能够深入了解:

Response status code does not indicate success: 400 (Bad Request). Stack trace: at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at Microsoft.Owin.Security.Facebook.FacebookAuthenticationHandlerd__0.MoveNext() 

请注意,我已经修改了facebook应用以匹配制作url,回复等。

  private void ConfigureAuth(IAppBuilder app) { var cookieOptions = new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }; app.UseCookieAuthentication(cookieOptions); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Passive app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType); app.UseFacebookAuthentication(new FacebookAuthenticationOptions { AppSecret = ConfigurationManager.AppSettings["FacebookAppSecret"], AppId = ConfigurationManager.AppSettings["FacebookAppId"], Provider = new FacebookAuthenticationProvider() { OnAuthenticated = (context) => { context.Identity.AddClaim(new Claim( IdentityUtility.ExtendedClaimTypes.IdentityProvider, "Facebook")); return Task.FromResult(0); }, OnReturnEndpoint = (context) => { if(context.Identity == null) throw new Exception(context.Response.StatusCode.ToString()); return Task.FromResult(0); } } }); } 

此致,马丁