Search code examples
c#asp.netasp.net-profiles

Update an existing user's profile in ASP.NET


I want to change an existing user's profile without having to create a new profile for the user. For example: I have a user name Usr1 and I want to change only his age, how do I do that?


Solution

  • See this article for the full details. Be aware that in certain cases (see my comment to another answer), ProfileCommon is not generated.

    In this case you need to revert to using ProfileBase:

    ProfileBase profile = context.Profile;
    DateTime dob= profile.GetPropertyValue("dob") as DateTime;
    ...
    profile.SetPropertyValue("dob",dob);