Base solution for your next web application
Open Closed

ObjectDisposedException on GenerateEmailConfirmationToken #1353


User avatar
0
eu11111 created

I am trying to generate an email confirmation token, but I am getting the following error:

Exception thrown: 'System.ObjectDisposedException' in mscorlib.dll

var user = await GetCurrentUserAsync();            
var token = _userManager.GenerateEmailConfirmationToken(user.Id);

EDIT > I also tried

var user = await GetCurrentUserAsync();            
var token = UserManager.GenerateEmailConfirmationToken(user.Id);

Could somebody help me? Thanks in advance.

EDIT> I got it working by setting the provider manually

var provider = new DpapiDataProtectionProvider("AppName");

_userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long>(provider.Create("TokenPurpose")) as IUserTokenProvider<User, long>;

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Thank you for sharing your solution.