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