I have table UserProfile
, where I have some additional fields, as email, typeAccount, isActivated etc.
When I get Membership.GetUser().(..)
, I don't have these fields.
How to resolve it? And how to change value of this fields?
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public string Email { get; set; }
public int typeAccount { get; set; }
public bool activated { get; set; }
public string activationcode { get; set; }
public bool del { get; set; }
}
Regards
The membership provider is not handling profiles. If you want to retrieve the UserProfile record of the currently authenticated user simply use the context:
[Authorize]
public ActionResult SomeAction()
{
using (UsersContext db = new UsersContext())
{
UserProfile user = db
.UserProfiles
.FirstOrDefault(u => u.UserName == User.Identity.Name);
// do something with the profile
}
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.