【问题标题】:Activation email in vb.net identityvb.net 身份中的激活电子邮件
【发布时间】:2018-08-11 21:12:39
【问题描述】:

我希望有人能给我一些启示,我有一个用户可以注册的应用程序,并且在 register.aspx.vb 文件中有未注释的行以允许电子邮件。

   Protected Sub CreateUser_Click(sender As Object, e As EventArgs)
    Dim userName As String = Email.Text
    Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
    Dim signInManager = Context.GetOwinContext().Get(Of ApplicationSignInManager)()
    Dim user = New ApplicationUser() With {.UserName = userName, .Email = userName}
    Dim result = manager.Create(user, Password.Text)
    If result.Succeeded Then
        ' For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
        Dim code = manager.GenerateEmailConfirmationToken(user.Id)
        Dim 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>.")

        signInManager.SignIn(user, isPersistent := False, rememberBrowser := False)
        IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
    Else
        ErrorMessage.Text = result.Errors.FirstOrDefault()
    End If
End Sub

但问题是,我需要添加类似于http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity#email 的电子邮件设置,但不知道如何调用它,这需要进入 EmailService 下的 Identity.config 吗?我需要在 web.config 中添加一些东西吗????

【问题讨论】:

    标签: asp.net vb.net asp.net-identity


    【解决方案1】:

    将详细信息添加到您的 web.config:

    <system.net>
        <mailSettings>
            <smtp from=“-your-sending-email-address-">
                <network defaultCredentials="false" host=“-mail.example.com-" password=“—password-" userName=“—email—account-" />
            </smtp>
        </mailSettings>
    </system.net>
    

    更多信息:https://msdn.microsoft.com/en-us/library/w355a94k(v=vs.110).aspx

    【讨论】:

      猜你喜欢
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 2014-06-24
      • 2014-02-10
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多