title: Email Confirmation ASP.NET Identity 2 OWIN MVC and API Invalid Token
body: <p>I'm attempting to get ASP.NET Identity 2.0 working for email validation.  The user account is created successfully, and a validation email is sent.</p>
  
  <p>If i validate the token in a web api Controller it works.
  If I validate the token in a mvc controller it does not, I'm not sure what I've got wrong.  </p>
  
  <p>The error returned from the MVC controller is "Invalid token"
  The api and mvc run on different ports and exist in separate assemblies.</p>
  
  <p>Here is some code fragments of the relevant parts.</p>
  
  <pre><code>//Startup.cs
  app.CreatePerOwinContext&lt;ApplicationUserManager&gt;(ApplicationUserManager.Create);
  
  //ApplicationUserManager.cs
  
  manager.EmailService = new EmailService();
  var dataProtectionProvider = options.DataProtectionProvider;
  manager.UserTokenProvider = new DataProtectorTokenProvider&lt;ApplicationUser&gt;(dataProtectionProvider.Create("ASP.NET Identity"));
  
  
  
  //MVC Controller
  
  public ApplicationUserManager UserManager
          {
              get { return this._userManager ?? this.HttpContext.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;(); }
              private set { this._userManager = value; }
          }
  ...
  UserManager.ConfimEmailAsync(userid,ConfirmationCode)
  
  
  //Web API Controller
  var result = this.UserManager.ConfirmEmail(model.UserId, model.ConfirmationToken);
  </code></pre>