Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity ConfirmAccount Method

WebSecurity - ConfirmAccount()


WebSecurity Object WebSecurity object


define

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


C# and VB syntax

WebSecurity.ConfirmAccount(

accountConfirmationToken

)


Example

Example 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";

    }

}

Example 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


Parameters

Parameters Type Description
accountConfirmationToken String The account confirmation token

Return Value

Type Description
Boolean Returns if the account is confirmed true; otherwise, returns false。

Errors and exceptions

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


Notes

The account confirmation token can be created via the CreateAccount()、 CreateUserAndAccount() or GeneratePasswordResetToken() method.

The general procedure is to send the token to the user by email, asking the user to verify their identity (via a link to the confirmation page).


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object