Search code examples
identityemail-confirmation

Idenitity UserManager ConfirmEmailAsync error


Visual Studio 2013 / MVC 5 / Identity 2

Still a bit new to using built in email confirmation...

testing under localhost - no errors

in production - I am getting an error when user tries to confirm email

var result = await UserManager.ConfirmEmailAsync(userId, code);

On the server, result.Succeeded is always false.

Where should I look to see an error? It's on GoDaddy server so I don't have complete access...


Solution

  • Where do you create "UserTokenProvider" for the user manager?

    I think this is something to do with that, because you need to make sure that,

    UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
    

    and

    UserManager.ConfirmEmailAsync(userId, code);
    

    both uses the same DataProtectorTokenProvider.

    manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
    

    Make sure you create this during the startup which will help you to keep one per owin request.