繁体   English   中英

ASP.NET Web Forms 用户注册 Email 不存在

[英]ASP.NET Web Forms User Registration Email Confirmation, IdentityHelper does not exist

Following the tutorial Create a secure ASP.NET Web Forms app with user registration, email confirmation and password reset (C#) I get to the section ' Enable Email Confirmation ' however, on the line 'string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id , 要求);' 'IdentityHelper' 不存在,我无法继续。

快速操作建议使用 Microsoft.TeamFoundation.Framework.Client,但是这不包含任何“GetUserConfirmationRedirectURL”,所以这并不是很有帮助。

我在网上搜索了替代教程,但没有发现对 ASP.NET Web Forms 没有任何帮助。

    protected void CreateUser_Click(object sender, EventArgs e)
    {
        // Default UserStore constructor uses the default connection string named: DefaultConnection
        var userStore = new UserStore<IdentityUser>();
        var manager = new UserManager<IdentityUser>(userStore);
        var user = new IdentityUser() { UserName = reg_UserName.Text, Email = reg_Email.Text };

        IdentityResult result = manager.Create(user, Password.Text);

        if (result.Succeeded)
        {
            var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
            var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

            string code = manager.GenerateEmailConfirmationToken(user.Id);
            string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
            manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

            authenticationManager.SignIn(new AuthenticationProperties() { }, userIdentity);
            Response.Redirect("~/Login.aspx");
        }
        else
        {
            StatusMessage.Text = result.Errors.FirstOrDefault();
        }

    }
}

}

“当前上下文中不存在名称‘IdentityHelper’”。

IdentityHelper 是否不再受支持?

提前感谢您的阅读,并希望您能提供帮助。

这是我的 static class IdentityHelper 的图像

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM