Asp.NET Identity 2 giving “Invalid Token” error

前端 未结 21 1924
情话喂你
情话喂你 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:36

    Other than that, I've seen the code itself fail if it's not encoded.

    I've recently started encoding mine in the following fashion:

    string code = manager.GeneratePasswordResetToken(user.Id);
    code = HttpUtility.UrlEncode(code);
    

    And then when I'm ready to read it back:

    string code = IdentityHelper.GetCodeFromRequest(Request);
    code = HttpUtility.UrlDecode(code);
    

    To be quite honest, I'm surprised that it isn't being properly encoded in the first place.

提交回复
热议问题