在确认邮件中包含所选密码



我正在使用asp.net身份并通过邮件发送一个确认链接,如

public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ConfirmEmail", "Account",
                       new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id,
                       "Confirm Account", "Confirm your Account, click the link <a href=""
                       + callbackUrl + "">här</a>.");
                    ViewBag.Message = "Email sent "
                + "more text.";
                    return View("Info");
                }

我想在邮件中包括他们在注册时选择的密码(纯文本)。我该怎么做?

public async Task<ActionResult> Register(RegisterViewModel model)
{
 if (ModelState.IsValid)
 {
  var user = new ApplicationUser { UserName = model.Email, Email = 
  model.Email };
  var result = await UserManager.CreateAsync(user, model.Password);
  if (result.Succeeded)
  {
   string code = await 
   UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
   var callbackUrl = Url.Action("ConfirmEmail", "Account",
   new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
   await UserManager.SendEmailAsync(user.Id, "Confirm Account",  
   "Confirm your Account, click the link <a href=""
   + callbackUrl + "">här</a>.your password is :  "+ model.Password);
   ViewBag.Message = "Email sent " + "more text.";
   return View("Info");
  }
 }
}

相关内容

  • 没有找到相关文章