ASP.NET Core Identity invalid token on confirmation email

前端 未结 7 1525
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 12:11

This is a very similar question to this aspnet identity invalid token on confirmation email but the solutions are not valid because I am using the new ASP.NET Core 1.0 that

7条回答
  •  孤独总比滥情好
    2021-01-01 12:41

    (according this post: https://stackoverflow.com/a/27943434/9869427)

    For the resetPasswordAsync (identity manager) "token invalid" problem... because "+" become space in url... use Uri.EscapeUriString

    exemple: in my sendResetPasswordByMailAsync

    var token = "Aa+Bb Cc";
    var encodedToken = Uri.EscapeDataString(token); 
    

    encodedToken = "Aa%20Bb2B%Cc"

    var url = $"http://localhost:4200/account/reset-password?email={email}&token={encodedToken}";
    var mailContent= $"Please reset your password by clicking here.";
    

    Now u can click on your link, and you will go to the good url with "+" (encode by %2B)... your token won't be invalid...

提交回复
热议问题