我正在使用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");
}
我想在邮件中注明他们选择的密码(纯文本)。我怎么能这样做?
答案 0 :(得分:0)
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");
}
}
}