Creating multiple users in membership once RRS feed

  • Question

  • User1623409651 posted

    Hi all,

    I have implemented asp.net membership in one of my project. now instead of creating user one by one we need to import list of users in once .  Is there any way to upload user details from excel to membership tables . like membership , roles etc.

    Thanking you,


    Monday, February 15, 2016 5:49 AM


  • User614698185 posted

    Hi Rameezwaheed,

    If you want to import the records into the membership database, you could refer to below code:

    foreach (record in recordset) {
        if (!(Roles.RoleExists(record["Role"])) {
        if (Membership.GetUser(record["Username"]) == null) {
            System.Web.Security.MembershipCreateStatus status;
            Membership.CreateUser(record["Username"], record["Password"], record["Email"], record["RSecurityQuestion"], record["SecurityAnswer"], true, status);
            if (status == System.Web.Security.MembershipCreateStatus.Success) {
                Roles.AddUserToRole(record["Username"], record["Role"]);

    Best regards,

    Candice Zhou

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 16, 2016 5:21 AM