I\'m trying to build Custom Membership Provider. I would like to capture additional information (First Name and Last Name) during the registration and I\'m not using usernam
The problem here is the Membership provider class doesn't give you a first and last name. You could store these in the profile however. In that case you need to go into AccountController.cs class and change 1. the interface
public interface IMembershipService
{
int MinPasswordLength { get; }
bool ValidateUser(string userName, string password);
MembershipCreateStatus CreateUser(string userName, string password, string email);
bool ChangePassword(string userName, string oldPassword, string newPassword);
}
and add a new CreateUser method signature with the fields you want.
Then you will need to implement this method in the AccountController class in that file.
The article you mention below says:
"However, this overload will not be called by the Membership class or controls that rely on the Membership class, such as the CreateUserWizard control. To call this method from an application, cast the MembershipProvider instance referenced by the Membership class as your custom membership provider type, and then call your CreateUseroverload directly. "
So - you cannot call the built in CreateUser as they mention Try casting the call in your new CreateUser method to be
public MembershipCreateStatus CreateUser(string firstName, string lastName, string password, string email)
{
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");
//etc....
MembershipCreateStatus status;
((YourCustomProvider)_provider).CreateUser(firstName, lastName, password, email, null, null, true, null, out status); return status;
}