Facebook, Google OAuth fails sometimes on Azure

主宰稳场 提交于 2019-12-11 11:45:36

问题


I am using Asp.Net MVC OAuth login with facebook and google and strange thing that at some period it doesnot work

var externalIdentity =
                HttpContext.GetOwinContext()
                    .Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
   return RedirectToAction("Login");
}

Seems here it cant get user info and redirect to login page. I cant figure out why or what can cause that. I also have two slots beta and production.

So any suggestion or maybe somebody already have that and found way how to fix that?


回答1:


Finally after few weeks i solve my problem. Its really something strange and probably issue is because of azure, since beforemy implementation works on VMvare for 6 month.

in AccountController there is method

public ActionResult ExternalLogin(string provider, string returnUrl)

add there

Session.RemoveAll();

PS/ Firstly when I have seen this recommendation I did not understood how it can help but then next time when OAuth fails i just simply restarted WebApp and it starts working. By the way even now i dont understand what is going on with session but it works.



来源:https://stackoverflow.com/questions/35751137/facebook-google-oauth-fails-sometimes-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!