HttpAntiForgeryException (0x80004005): The provided anti-forgery token was meant for a different claims-based user than the current user

0

My Case is different , when I logged in to the application and then direct close the browser and then again open browser and go to login page TO click login button without entering the username or password it give me this error:

“The provided anti-forgery token was meant for a different claims-based user than the current user.”

and this issue is resolved when I refresh the page by using "ctrl+f5".

how to solve this thing I searched a lot and do at most all the things told by other persons.

  1. [AllowAnonymous]
  2. [OutputCache(NoStore = true, Location = OutputCacheLocation.None)]

add this to my controller action method and also use if session.abandon(); but nothing is changed and also i added machine key in my web config file but nothing is changed.

Note :- not using any form authentication in it.

    [AllowAnonymous]
    [OutputCache(NoStore = true, Location = System.Web.UI.OutputCacheLocation.None)]
    public ActionResult Login(string returnUrl)
    {

        Session.Abandon();
        Session.Clear();
        ViewBag.ReturnUrl = returnUrl;

        var AutheticationManager = HttpContext.GetOwinContext().Authentication;
        // AutheticationManager.SignOut();
        AutheticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

        LoginViewModel model = new LoginViewModel();
        if (Request.Cookies["unm"] != null)
        {
            HttpCookie unm = (HttpCookie)Request.Cookies["unm"];
            model.Email = unm.Value;
        }
        if (Request.Cookies["pas"] != null)
        {
            HttpCookie pas = (HttpCookie)Request.Cookies["pas"];
            model.Password = pas.Value;
        }
        if (Request.Cookies["rem"] != null)
        {
            HttpCookie rem = (HttpCookie)Request.Cookies["rem"];
            if (rem.Value.ToLower() == "true")
                model.RememberMe = true;
            else
                model.RememberMe = false;
        }


        return View();
    }

what I need to do to overcome this error. please let me know any help is very appreciated.

asp.net-mvc
asp.net-identity
asked on Stack Overflow May 28, 2019 by mitesh • edited May 29, 2019 by mitesh

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0