Latest web development tutorials

WebSecurity ConfirmAccount method

WebSecurity objects WebSecurity objects

definition

ConfirmAccount () method uses the account confirmation token to confirm and activate your account.


C # and VB syntax

WebSecurity.ConfirmAccount( accountConfirmationToken )


Examples

Examples of 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";
}
}

Examples 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


parameter

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


return value

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


Errors and exceptions

In the following scenario, any access to WebSecurity object will throw an InvalidOperationException:

  • InitializeDatabaseConnection () method has not been called
  • SimpleMembership not initialized (or disabled in the site configuration)

Remark

Account confirmation token by CreateAccount (), CreateUserAndAccount () or GeneratePasswordResetToken () method creates.

The general procedure is to send in an email to the user token to authenticate the user request (through a link to the confirmation page).


Technical data

名称
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity objects WebSecurity objects