简短的版本:
我有一个MVC5网站应用程序部署为一个Azure云服务web角色。使用Owin作为登录流。在本地主机上测试站点时,Owin集成可以正常工作,但是在生产服务器上,GetExternalLoginInfoAsync()正在从signin的回调中返回null。
一些细节:
查看Chrome中的DevTools:
Re.部署:
下面是显示处理的代码片段(ChallengeResult是当前的WebApplication模板代码)。控制器被标记为OutputCache(Location = OutputCacheLocation.None),没有标记为授权
// POST: /Membership/ExternalSignupDispatch (They clicked to login with Facebook, Google, etc.)
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ExternalSignupDispatch(string provider, string community = Communities.Dating)
{
// Request a redirect to the external login provider
return new ChallengeResult(provider, Url.Action("ExternalSignupCallback1", "Membership", new { community }));
}
// GET: /Membership/ExternalSignupCallback
public async Task<ActionResult> ExternalSignupCallback1(string community = Communities.Dating)
{
var info = await AuthenticationManager.GetExternalLoginInfoAsync();
if (info == null) // Unsuccessful login
{制作服务器上Owin/Facebook的无声故障令人恼火。如果有错误枚举..。或者一个例外..。但是唉
任何想法都是非常感谢的!
发布于 2019-03-04 21:48:18
所以。事实证明,如果没有预先存在的ASP.NET_SessionID cookie,Owin目前将以神秘的方式失败。没有它,signin函数不会删除.Aspnet.Correlation.Facebook cookie,也不会设置.Aspnet.ExternalCookie cookie。会话ID cookie的不存在在某种程度上阻止了所需的cookie处理。所有这些都为间歇性无声故障设置了舞台,这取决于客户端的cookie状态。
解决方法是在使用Facebook登录生成表单时存储一个假会话变量,强制在登录SessionID之前创建cookie。
注意,我们正在使用SystemWebCookieManager (希望避免此类cookie问题)。事情似乎还在发展。
作为参考,下面是我们的ConfigureAuth函数中的cookie设置:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieManager = new SystemWebCookieManager(),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(Params.LoginExpiryMinutes),
SlidingExpiration = true,
LoginPath = new PathString("/Login"),
Provider = new CookieAuthenticationProvider // Used to allow returning 401 Unauthorized status to API calls, instead of 302 redirect
{
OnApplyRedirect = ctx =>
{
if (!IsAjaxRequest(ctx.Request))
{
ctx.Response.Redirect(ctx.RedirectUri);
}
}
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);https://stackoverflow.com/questions/54953058
复制相似问题