4

When i try to login with an external provider the first time this return null then i press again in the provider and everything is fine. I think is something with cookies because the error happen when i delete all cookies and try again.

If I remove all Session and TempData everything works OK, why is that?

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");
    }
}
Oswaldo Alvarez
  • 4,772
  • 1
  • 22
  • 20

1 Answers1

3

i have to create a filter an put the following

 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)
        {

        }
    }
Oswaldo Alvarez
  • 4,772
  • 1
  • 22
  • 20