ConfirmAccount()

阅读:52      收藏:0      [点我收藏+]

WebSecurity - ConfirmAccount()


定义

ConfirmAccount() 方法使用帐户确认令牌确认并激活帐户。


C# 和 VB 语法

WebSecurity.ConfirmAccount(accountConfirmationToken)


实例

实例 C#

string message = "";
var confirmationToken = Request["confirmationCode"];

WebSecurity.Logout();

if (!confirmationToken.IsEmpty())
{
  if (WebSecurity.ConfirmAccount(confirmationToken))
  {
  message = "Registration confirmed";
  }
  else
  {
  message = "Could not confirm your registration";
  }
}

实例 VB

message = ""
confirmationToken = Request("confirmationCode")

WebSecurity.Logout()

if !confirmationToken.IsEmpty() then
 if WebSecurity.ConfirmAccount(confirmationToken) then
 message = "Registration Confirmed"
  else
 message = "Could not confirm your registration"
  end if
end if


参数

参数 类型 描述
accountConfirmationToken String 帐户确认令牌


返回值

类型 描述
Boolean 如果帐户已确认,则返回?true,否则返回 false


错误和异常

在下面的情况下,任何对 WebSecurity 对象的访问将抛出一个 InvalidOperationException

  • InitializeDatabaseConnection() 方法没有被调用
  • SimpleMembership 没有初始化(或者在网站配置中禁用)

备注

帐户确认令牌可通过 CreateAccount()CreateUserAndAccount()GeneratePasswordResetToken() 方法创建。

一般过程是在电子邮件中向用户发送令牌,请求用户验证身份(通过一个指向确认页面的链接)。


技术数据

名称
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!