Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this code to show user profile properties


C#
var currentUserId = User.Identity.GetUserId();
            var manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext()));
            var currentUser = manager1.FindById(User.Identity.GetUserId());
            TextBox1.Text = currentUser.UserInfo.FullName;


But how can update user profile properties below code is not working


C#
var currentUserId = User.Identity.GetUserId();
            var manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext()));
            var currentUser = manager1.FindById(User.Identity.GetUserId());
            currentUser.UserInfo.FullName = TextBox1.Text;
Posted
Updated 4-Aug-14 5:18am
v3
Comments
Dave Kreskowiak 4-Aug-14 14:10pm    
OK, so did you put code in to SaveChanges back to the database? It doesn't look like it.

1 solution

I am using this class

C#
public class ApplicationUser : IdentityUser
    {
        public virtual UserInfo UserInfo { get; set; }
    }
    public class UserInfo
    {
        public int Id { get; set; }
        public string FullName { get; set; }
        
    }
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("AP")
        {
        }
        public System.Data.Entity.DbSet<UserInfo> UserInfo { get; set; }
    }



and

C#
var manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext()));
            var currentUser = manager1.FindById(User.Identity.GetUserId());
            currentUser.UserInfo.FullName = TextBox1.Text</applicationuser></applicationuser>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900