Authentication Authorization ASP.Net Tutorial

<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    protected void CreateUserWizard1_SendingMail(object sender, MailMessageEventArgs e)
    {
        MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName);
        string code = user.ProviderUserKey.ToString();
        e.Message.Body = e.Message.Body.Replace("<%ConfirmationCode%>", code);
    }



    CreateUserWizard Code Confirmation


    
    

            id="CreateUserWizard1"
        CompleteSuccessText="A confirmation email
            containing your new password has been
            sent to your email address."
        DisableCreatedUser="true"
        ContinueDestinationPageUrl="~/ConfirmCode.aspx"
        OnSendingMail="CreateUserWizard1_SendingMail"
        Runat="server">
                    From="Admin@YourSite.com"
            BodyFileName="CodeConfirmation.htm"
            IsBodyHtml="true"
            Subject="Registration Confirmation" />
    
    

    


            
File: CodeConfirmation.htm
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Code Confirmation


<%UserName%>,
your confirmation code is <%ConfirmationCode%>


File: ConfirmCode.aspx
Code View: Scroll / Show All
<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser(txtUserName.Text);
        if (user == null)
        {
            lblError.Text = "Invalid User Name";
        }
        else
        {
            string providerCode = user.ProviderUserKey.ToString();
            string userCode = txtConfirmationCode.Text.Trim();
            if (providerCode != userCode)
            {
                lblError.Text = "Invalid Confirmation Code";
            }
            else
            {
                user.IsApproved = true;
                Membership.UpdateUser(user);
                Response.Redirect("~/SecretFiles/Secret.aspx");
            }
        }
    }



    Confirm Code


    
    

    Enter the confirmation code that you received by email.
            id="lblError"
        EnableViewState="false"
        ForeColor="Red"
        Runat="server" />
    
            id="lblUserName"
        Text="User Name:"
        AssociatedControlID="txtUserName"
        Runat="server" />
    
            id="txtUserName"
        Runat="server" />
    
            id="lblConfirmationCode"
        Text="Confirmation Code:"
        AssociatedControlID="txtConfirmationCode"
        Runat="server" />
    
            id="txtConfirmationCode"
        Columns="50"
        Runat="server" />
            id="btnConfirm"
        Text="Confirm"
        OnClick="btnConfirm_Click"
        Runat="server" />