Di recente ho aggiornato il Asp.Net Identity Coremio modulo di domanda dalla 1.0 alla 2.0.
Ci sono nuove funzionalità che volevo provare GenerateEmailConfirmationToken, ecc.
Sto usando questo progetto come riferimento.
Quando l'utente prova a registrarsi, ottengo un errore durante l'esecuzione del metodo Post di Register
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);
}
In linea
var code = _userManager.GenerateEmailConfirmationToken(user.Id);
Ottengo un errore dicendo:
No IUserTokenProvider is registered.
Per ora, volevo solo vedere che tipo di codice genera. C'è qualche cambiamento che devo apportare alla mia ApplicationUserclasse che eredita dalla IdentityUserclasse?
O c'è qualcosa che devo cambiare per far funzionare quelle funzioni?