The provided antiforgery token was meant for a different claims-based user than the current user. means the form was rendered for one user (or for nobody) and posted after the request's user changed: a sign-in or a switch to another account in between. Render the form again after the sign-in and post that one.

In the test, fetching the form again after the sign-in and posting that copy was accepted. A sign-out was not tested.

The error

PS> curl.exe -s -i -b jar.txt -d "@body.txt" -H "Accept: text/plain" http://127.0.0.1:15610/book | Select-Object -First 12
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
...

Microsoft.AspNetCore.Http.BadHttpRequestException: Invalid anti-forgery token found when reading parameter "string name" from the request body as form.
 ---> Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The provided antiforgery token was meant for a different claims-based user than the current user.
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateTokens(HttpContext httpContext, AntiforgeryTokenSet antiforgeryTokenSet)
...

This is the response body of a minimal API form post in the Development environment; the request sent Accept: text/plain and the body was this text.

Why it happens

In both cases below the signed-in user changed between rendering and posting the form, the message says the token was meant for a different user than the current one, and a form fetched again after the sign-in was accepted. The test reproduced two cases with one cookie jar. First it fetched /form anonymously, signed in as maria with the test's /login endpoint, and posted the anonymous form: 400 with the message above. Then it fetched the form as maria, signed in as david in the same jar, and posted maria's form: the same message.

PS> curl.exe -s -b jar.txt -c jar.txt http://127.0.0.1:15610/form -o form.html
(wrote body-m.txt: name=Maria%20Garcia&__RequestVerificationToken=<token from form.html>)
PS> curl.exe -s -b jar.txt -c jar.txt "http://127.0.0.1:15610/login?user=david"
Signed in as david.
PS> curl.exe -s -i -b jar.txt -d "@body-m.txt" -H "Accept: text/plain" http://127.0.0.1:15610/book | Select-Object -First 9
HTTP/1.1 400 Bad Request
...
 ---> Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The provided antiforgery token was meant for a different claims-based user than the current user.
...

The fix

PS> curl.exe -s -b jar.txt -c jar.txt http://127.0.0.1:15610/form -o form.html
(wrote body-d.txt: name=Maria%20Garcia&__RequestVerificationToken=<token from form.html>)
PS> curl.exe -s -i -b jar.txt -d "@body-d.txt" -H "Accept: text/plain" http://127.0.0.1:15610/book
HTTP/1.1 200 OK
...

Booked for Maria Garcia.

Fetching the form again while signed in as david, then posting it, gave 200. In an app that would mean showing the form again after the login, for example with a redirect to the form page; that redirect is advice, not something this test ran.

How it was reproduced

A project from dotnet new web -n AfLab -f net10.0 on .NET SDK 11.0.100, no NuGet packages, running on ASP.NET Core 10.0.15 in Development on 127.0.0.1:15610, with cookie authentication (AddAuthentication().AddCookie()), a test-only GET /login?user= endpoint that signs in a user without a password, a GET /form endpoint that writes the hidden field from IAntiforgery.GetAndStoreTokens, a POST /book endpoint with [FromForm] string name and app.UseAntiforgery(). Requests went through curl 8.22.0 with one cookie jar file. The user names are the test's own.

Frequently asked

Why do I get antiforgery token meant for a different claims-based user after login?
The form was rendered before the login, when nobody was signed in. In the test, posting that form after signing in returned 400; fetching the form again after the login returned 200.
Does switching accounts break antiforgery tokens?
Yes, in the test a form rendered for one user and posted after signing in as another user with the same curl cookie jar gave the same different claims-based user message.
How do I avoid the different claims-based user error?
Fetch the form again after the sign-in or account switch and post that copy; in the test that returned 200. A redirect to the form page after login is the usual way to do that in an app; it was not tested here.

More decoded errors in the Fixes category. When the cookie and the field come from two different sessions instead, the message is The antiforgery cookie token and request token do not match.