I have a site that receives a large amount of the following errors:
The provided anti-forgery token was meant for a different claims-based user than the current user.
The anti-forgery cookie token and form field token do not match.
I would like to prevent the site from throwing an error if the anti-forgery token is meant for no user but contains a user on the login page, for example:
The provided anti-forgery token was meant for user "", but the current user is "Garret".
I don't want this exception to apply to any other page other than the login page. So I don't want to add AntiForgeryConfig.SuppressIdentityHeuristicChecks = true; to the entire site. I also want to keep the site as secure as possible since it contains HIPAA data. What can I do to keep it as secure as possible but still try to prevent this error on the login page because it is making it difficult for users to use?
The site is hosted on load balancing servers but I don't think this is the issue. I think the error is mostly caused by using the browser's back button, having the login page opened for a while before logging in, already being logged in or pressing login more than once. Also some users access it through an application that may not be loading the page and just trying to post the login information.
So please let me know what the best option is to prevent this error on the login page while still being as secure as possible?