Last post Dec 30, 2016 02:34 AM by Chris Zhao
Dec 29, 2016 10:17 PM|crhama|LINK
The following method is in the repository and helps reset the password. The problem is that I'm getting an 'Invalid Token' error only in the production server. Things are working just fine on my
local machine or on the Test server.
public static bool ResetPassword(string userName, string newPassword,
HttpContext context, bool ExpirePassword = false)
var manager = context.GetOwinContext().GetUserManager<UserManager>();
var user = manager.FindByName(userName);
if (user == null)
var code = manager.GeneratePasswordResetTokenAsync(user.Id).Result;
code = code.Replace(" ", "+");
var result = manager.ResetPassword(user.Id, code, newPassword); //this line is causing problem ... invalid token.
user.PasswordToReset = true;
//Log the error
The application was tested fine in the Test server. We deployed that today and nobody can reset the password because of the invalid token.
Thanks for helping
Dec 30, 2016 02:34 AM|Chris Zhao|LINK
URL encoding converts characters that are not allowed in a URL into character-entity equivalents. The UrlEncode method converts each space character to a plus character (+).