I have this functionality that needs to reset the password of my user. But I just could not make it because the MembershipUser keeps on throwing 'Data is Null' error. The membership provider in my web.config does allow Reset, does not allow password retrieval and does not require Question and Answer.

 

       <membership defaultProvider="MySQLMembershipProvider">
            <providers>
                <clear/>
                <add name="MySQLMembershipProvider"
                connectionStringName="MyConnection"
                applicationName="/"
                autogenerateschema="true"
                type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=5.2.2.0,

                Culture=neutral, PublicKeyToken=c5687fc88969c44d"
                enablePasswordReset="true"
                requiresQuestionAndAnswer="false"             
               requiresUniqueEmail="true"
               passwordFormat="hashed"
            />
            </providers>
        </membership>

  Although, creating a user without requiring for question and answer will succeed. Question and Answer is still required for reseting his password. So, how can your application handle the scenario where in you will not require you user to enter Question and Answer upon registration but still be able to reset his password? What I did was handle the Question and Password in 'CreatingUser' event of the CreateUserWizard cotrol. 

  protected void CreatingUser(object sender, LoginCancelEventArgs e)
    {
        CreateUserWizard cuw = (CreateUserWizard)sender;
        cuw.Question = "your-own-question";
        cuw.Answer = "your-own-answer";

    }

 

That piece of code will make your Reset() method to work but still the GetPassword() will not.