Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Bruce 122 posts 506 karma points
    Apr 27, 2021 @ 07:09
    Tom Bruce
    0

    Change UserName

    Hi everyone, how do you change a username?

    I am trying to create method within a helper class to change the User.Name

    I have the following code, but I am receiving an error

    “MembershipUserName cannot be assigned to – it is read only”

    MembershipUser currentUser = Membership.GetUser(tempMemberEmail);
    
            if (currentUser != null)
            {
    
                currentUser.UserName = tempUserName;
                Membership.UpdateUser(currentUser);
            }
    

    Any pointers much appreciated.

  • AddWeb Solution Pvt. Ltd 109 posts 360 karma points
    Apr 29, 2021 @ 04:37
    AddWeb Solution Pvt. Ltd
    1

    Hello Tom,

    Try something like this

    var member = Services.MemberService.GetByusername(customer.LoginName);
    member.Username = "new value";
    Services.MemberService.Save(member);
    
Please Sign in or register to post replies

Write your reply to:

Draft