I've seen this discussed a few times but I still can't solve it.
My registration process works well 99% of the time. But the occasional time I get an invalid token error when confirming an email address (via a link in an email). I'm even URL encoding/decoding the token now too, but I still get the occasional error.
Register action:
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
code = System.Web.HttpUtility.UrlEncode(code);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
and Confirm action:
code = System.Web.HttpUtility.UrlDecode(code);
var result = await UserManager.ConfirmEmailAsync(userId, code);
I can confirm each 'failing' user does have a Security Stamp. And the name/username doesn't appear to contain any dodgy characters.
Is there anything else I can check?