ASP.NET MVC The provided anti-forgery token was meant for a different claims-based user …

Problem:

Steps:

  1. Navigate to Login page.
  2. Login as user A
  3. Press browser’s Back button to navigate to Login page ahead.
  4. Login as user B

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

 

Solution:

One simple solution that works for me is to disable the caching of the login page.

   1: //

   2: // GET: /Account/Login

   3: [AllowAnonymous]

   4: // disable caching on login page to avoid "the provided anti-forgery token was meant for a different claims-based user"

   5: [OutputCache(NoStore = true, Location = OutputCacheLocation.None)]

   6: public ActionResult Login(string returnUrl)

   7: {

 

Reference:

http://stackoverflow.com/questions/24376800/the-back-button-and-the-anti-forgery-token

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s