C# 等待AuthenticationManager.GetExternalLoginInfoAsync()返回null

C# 等待AuthenticationManager.GetExternalLoginInfoAsync()返回null,c#,asp.net-mvc-5,owin,C#,Asp.net Mvc 5,Owin,当我第一次尝试使用外部提供程序登录时,返回null,然后再次按下提供程序,一切正常。我认为是cookies的问题,因为当我删除所有cookies并重试时会发生错误 如果我删除了所有会话和TempData,一切正常,为什么会这样 public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExter

当我第一次尝试使用外部提供程序登录时,返回null,然后再次按下提供程序,一切正常。我认为是cookies的问题,因为当我删除所有cookies并重试时会发生错误

如果我删除了所有会话和TempData,一切正常,为什么会这样

public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
    var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
    if (loginInfo == null)
    {
        Elmah.ErrorSignal.FromCurrentContext().Raise(new NotImplementedException("Error ExternalLoginCallback"));
        TempData["_Error"] = "El incio de sesión con redes sociales no está disponible en este moemento, intente con su usuario y clave";
        return RedirectToAction("Login");
    }
}
public异步任务ExternalLoginCallback(string returnUrl)
{
var loginInfo=await AuthenticationManager.GetExternalLoginInfoAsync();
if(loginInfo==null)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(新的NotImplementedException(“ErrorExternalLoginCallback”));
TempData[“_Error”]=“无可争议的社会行为,通常情况下的意图”;
返回重定向操作(“登录”);
}
}

我必须创建一个过滤器并放置以下内容

 public class FilterBase : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
                if (!filterContext.IsChildAction && !filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    /*
                     * MICROSOFT BUG
                     * http://stackoverflow.com/questions/20737578/asp-net-sessionid-owin-cookies-do-not-send-to-browser/21234614#21234614
                     * https://katanaproject.codeplex.com/workitem/197
                     */
                    filterContext.HttpContext.Session["Workaround"] = 0;

                }

        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {

        }
    }