Friday, October 7, 2022

Anti forgery token is meant for user "" but the current user is "loginusermainid"

 Login time, if we click ,multiple time we will get this exception. that time use application error and rediredt to after login page

protected void Application_Error(object sender, EventArgs e)

      {

           try

            {

                string controller = Request.RequestContext.RouteData.Values["controller"].ToString();

                string action = Request.RequestContext.RouteData.Values["action"].ToString();

                Exception exception = Server.GetLastError();

                if (exception != null)

                {

                    if (exception is HttpAntiForgeryException)

                    {

                        

                        Response.Redirect("~/Account/Dashboard");

                    }

                }

            }

            catch (Exception ex)

            {

             throw;

            }

        }