Asp.NET Identity 2 giving “Invalid Token” error

前端 未结 21 1945
情话喂你
情话喂你 2020-11-27 03:04

I\'m using Asp.Net-Identity-2 and I\'m trying to verify email verification code using the below method. But I am getting an \"Invalid Token\"

21条回答
  •  借酒劲吻你
    2020-11-27 03:42

    I was getting the "Invalid Token" error even with code like this:

    var emailCode = UserManager.GenerateEmailConfirmationToken(id);
    var result = UserManager.ConfirmEmail(id, emailCode);
    

    In my case the problem turned out to be that I was creating the user manually and adding him to the database without using the UserManager.Create(...) method. The user existed in the database but without a security stamp.

    It's interesting that the GenerateEmailConfirmationToken returned a token without complaining about the lack of security stamp, but that token could never be validated.

提交回复
热议问题