vb.net 身份的激活电子邮件



我希望有人能为我提供一些启发,我有一个应用程序,用户可以注册并在寄存器.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 的电子邮件设置,但不确定如何调用它,这是否需要进入电子邮件服务下的 Identity.config??? 我需要在 web.config 中添加一些东西吗????

将详细信息添加到您的 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

相关内容

  • 没有找到相关文章

最新更新