MembershipProvider.CreateUser Method

Adds a new membership user to the data source.

Namespace: System.Web.Security
Assembly: System.Web (in system.web.dll)

public abstract MembershipUser CreateUser (
	string username,
	string password,
	string email,
	string passwordQuestion,
	string passwordAnswer,
	bool isApproved,
	Object providerUserKey,
	out MembershipCreateStatus status
public abstract MembershipUser CreateUser (
	String username, 
	String password, 
	String email, 
	String passwordQuestion, 
	String passwordAnswer, 
	boolean isApproved, 
	Object providerUserKey, 
	/** @attribute OutAttribute() */ /** @ref */ MembershipCreateStatus status
Not applicable.



The user name for the new user.


The password for the new user.


The e-mail address for the new user.


The password question for the new user.


The password answer for the new user


Whether or not the new user is approved to be validated.


The unique identifier from the membership data source for the user.


A MembershipCreateStatus enumeration value indicating whether the user was created successfully.

Return Value

A MembershipUser object populated with the information for the newly created user.

Takes, as input, the name of a new user, a password, and an e-mail address and inserts a new user for the application into the data source. The CreateUser method returns a MembershipUser object populated with the information for the newly created user. The CreateUser method also defines an out parameter (in Visual Basic, you can use ByRef) that returns a MembershipCreateStatus value that indicates that the user was successfully created, or a reason that user creation failed.

The CreateUser method raises the ValidatingPassword event, if a MembershipValidatePasswordEventHandler event handler has been specified, and continues or cancels the create-user action based on the results of the event. You can use the OnValidatingPassword virtual method to execute the specified MembershipValidatePasswordEventHandler event handler.

For an example of a MembershipProvider implementation, see Implementing a Profile Provider.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0