I have recently migrated Asp.net identity 1.0 to 2.0 . I am trying to verify email verification code using below method. But i am getting "Invalid Token" error message.
public async Task<HttpResponseMessage> ConfirmEmail(string userName, string code)
{
ApplicationUser user = UserManager.FindByName(userName);
var result = await UserManager.ConfirmEmailAsync(user.Id, code);
return Request.CreateResponse(HttpStatusCode.OK, result);
}
Generating Email verification token using below code (And if i call ConfirmEmailAsyc immediate after generating token, which is working fine). But when i am calling using different method which is giving error
public async Task<HttpResponseMessage> GetEmailConfirmationCode(string userName)
{
ApplicationUser user = UserManager.FindByName(userName);
var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
//var result = await UserManager.ConfirmEmailAsync(user.Id, code);
return Request.CreateResponse(HttpStatusCode.OK, code);
}
Please help