我最近将Asp.Net Identity Core
申请表1.0 更新为2.0。
有一些我想尝试的新功能,例如GenerateEmailConfirmationToken
等等。
我正在使用这个项目作为参考。
当用户尝试注册时,执行Register的Post方法时会出错
private readonly UserManager<ApplicationUser> _userManager;
public ActionResult Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var ifUserEXists = _userManager.FindByName(model.EmailId);
if (ifUserEXists == null) return View(model);
var confirmationToken = _userRepository.CreateConfirmationToken();//this is how i'm generating token currently.
var result = _userRepository.CreateUser(model,confirmationToken);
var user = _userManager.FindByName(model.EmailId);
if (result)
{
var code = _userManager.GenerateEmailConfirmationToken(user.Id);//error here
_userRepository.SendEmailConfirmation(model.EmailId, model.FirstName, confirmationToken);
//Information("An email is sent to your email address. Please follow the link to activate your account.");
return View("~/Views/Account/Thank_You_For_Registering.cshtml");
}
}
//Error("Sorry! email address already exists. Please try again with different email id.");
ModelState.AddModelError(string.Empty, Resource.AccountController_Register_Sorry__User_already_exists__please_try_again_);
return View(model);
}
在行中
var code = _userManager.GenerateEmailConfirmationToken(user.Id);
我收到错误消息:
No IUserTokenProvider is registered.
现在,我只想看看它生成什么样的代码。我需要对ApplicationUser
从IdentityUser
类继承的类进行一些更改吗?
还是我需要更改某些功能才能使这些功能正常工作?