我添加了一些新的屬性asp.net身份2.2.1(AspNetUsers表)代碼首先如何另一個Propertys加入User.Identity從表AspNetUsers身份2.2.1
public class ApplicationUser : IdentityUser
{
public string AccessToken { get; set; }
public string FullName { get; set; }
public string ProfilePicture { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
好了,現在我想打電話頭像像這樣的代碼: User.Identity.ProfilePicture;
的解決方案是:
你需要創建一個實施的IIdentity和 IPrincipal的自己的類。然後在 OnPostAuthenticate分配他們在您的Global.asax。
但我不知道如何做到這一點!如何創建自己的實現IIdentity和IPrincipal的類。然後在OnPostAuthenticate的global.asax中分配它們。 謝謝。
非常感謝你:) – MoHaMmAd