Is it possible to change the username with the Membership API

后端 未结 7 2053
独厮守ぢ
独厮守ぢ 2020-12-03 13:38

I am using the default sql membership provider with ASP.NET and I would like to provide a page to change the user\'s username. I believe I am sure I could do this with a cus

7条回答
  •  無奈伤痛
    2020-12-03 13:51

    If you want to do that with the Membership API, it seems the right way would be like this:

    http://omaralzabir.com/how_to_change_user_name_in_asp_net_2_0_membership_provider/

    Basically, you have to do the following (I copied from the above link, for sake of completeness):

    1. Create a new user using the new email address
    2. Get the password of the old account and set it to the new account. If you can’t get the old password via Membership provider, then ask user.
    3. Create a new profile for the new user account
    4. Copy all the properties from the old profile to the new profile object.
    5. Log out user from old account
    6. Auto sign in to the new account so that user does not notice what an incredible thing just happened.

提交回复
热议问题