I've implemented ASP.NET Identity in my MVC application by copying the code from the VS 2013 templates. The basic thing is working, but I couldn't get the Reset Password to work. When I show the "forgot password" page an email is generated which contains the token. This token is returned by the method:
UserManager.GeneratePasswordResetTokenAsync(user.Id)
When I click the link the reset password forms open and lets the user input their email address and a new password. Then the call to the change password functionality is made:
UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
This looks good to me, but the result is always a "Invalid Token" and I don't get why that is.
Does anybody have an idea why it isn't working? And where the hell is the token stored? I thought it must be in the database somewhere around the AspNetUsers
table...
The token generated by
UserManager
in ASP.NET Identity usually contains "+
" characters which when passed as a query string get changed into "" (a space) in the URL. In your ResetPassword ActionResult replace "
" with "
+
" like this:That should do the trick. I had the same problem and found the answer here.