我最近更新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类的类进行一些更改吗?
或者我需要改变什么才能让这些功能正常工作?