June 27, 2014

The provided Anti-Forgery Token was meant for user "", but the current user is "admin@abcd.com"

This error is occur when you are developing the MVC application in Asp.Net.

When this error arise?

This error occurs when the user enter their credentials (username & password) and click login. After the successfully authenticate the credentials, user will navigate to Home page of their portal. Here if user uses the browser back to move back to login page, then re-enter their credentials again and clicking on the login button. This time user will see this error on their screens.

How to Fix?

To fix the error you have to place the OutputCache Data Annotation on the Get ActionResult of Login page as:

[OutputCache(NoStore=true, Duration = 0, VaryByParam= "None")] 
public ActionResult Login(string returnUrl)

Horaaah! You fix it. Isn't the simple way to solve the problem in quick way when you are building the application on MVC

2 comments:

  1. thanks. it really helped

    ReplyDelete
  2. Wow, cool post. I’d like to write like this too – taking time and real hard work to make a great article… but I put things off too much and never seem to get started. Thanks though. SEO

    ReplyDelete