【问题标题】:Password recover MVC 5: UserManager.GenerateEmailConfirmationTokenAsync not available in ASP.NET密码恢复 MVC 5:UserManager.GenerateEmailConfirmationTokenAsync 在 ASP.NET 中不可用
【发布时间】:2014-10-01 22:05:21
【问题描述】:

我试图在这里使用 Rick Anderson 的示例实现密码重置令牌 http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity

当我在自己的应用程序中尝试忘记密码控制器的代码时,我没有选择 UserManager.GenerateEmailConfirmationTokenAsync 的选项。有没有人遇到过这个?我正在使用 MVC 5。这可能是 Visual Studio 版本/更新问题吗?我正在使用 VS 2013(版本 12.0.21005.1 REL)。

谢谢,

桑吉夫

public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
    if (ModelState.IsValid)
    {
        var user = await UserManager.FindByNameAsync(model.Email);
        if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
        {
            // Don't reveal that the user does not exist or is not confirmed
            return View("ForgotPasswordConfirmation");
        }

        var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
        var callbackUrl = Url.Action("ResetPassword", "Account", 
        new { UserId = user.Id, code = code }, protocol: Request.Url.Scheme);
        await UserManager.SendEmailAsync(user.Id, "Reset Password", 
        "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");        
        return View("ForgotPasswordConfirmation");
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-5 forgot-password


    【解决方案1】:

    好的,问题是我必须安装 Visual Studio Update 2。现在 GeneratePasswordResetToken 选项出现在 UserManager 下。

    【讨论】:

      猜你喜欢
      • 2011-03-10
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 2012-01-18
      • 2011-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多