小编Yas*_*utt的帖子

MVC 中的 ASP.NET Identity IUserEmailStore 错误

当用户与生成的令牌一起注册时,我试图发送确认电子邮件。令牌没问题。但是在发送电子邮件时,我收到此错误:

System.NotSupportedException: Store does not implement IUserEmailStore<TUser>.
Run Code Online (Sandbox Code Playgroud)

我在 Register 方法中 AccountController 中的代码如下所示: 导致错误的是 SendEmailAsync() 方法:

if (result.Succeeded)
{
    var 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 your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
    ViewBag.Link = callbackUrl;
    return View("DisplayEmail");
}
Run Code Online (Sandbox Code Playgroud)

在我的 IdentityConfig.cs 文件中,我有一个类:

public class ApplicationUserManager : UserManager<ApplicationUser>
{
        public ApplicationUserManager(IUserStore<ApplicationUser> store)
            : base(store)
        {
        } …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc identity usermanager

2
推荐指数
1
解决办法
2177
查看次数

标签 统计

asp.net-mvc ×1

identity ×1

usermanager ×1