title: Invalid Token. while verifying email verification code using UserManager.ConfirmEmailAsync(user.Id, code)
body: <p>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. </p>
  
  <pre><code>public async Task&lt;HttpResponseMessage&gt; ConfirmEmail(string userName, string code)
          {
              ApplicationUser user = UserManager.FindByName(userName);
              var result = await UserManager.ConfirmEmailAsync(user.Id, code);
              return Request.CreateResponse(HttpStatusCode.OK, result);
          }
  </code></pre>
  
  <p>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</p>
  
  <pre><code>public async Task&lt;HttpResponseMessage&gt; 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);
          }
  </code></pre>
  
  <p>Please help</p>