我为Asp.net Identity 2.2.1 (AspNetUsers表) Code First添加了一些新属性。
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。然后在global.asax的OnPostAuthenticate中分配它们。
但我不知道该怎么做!如何创建自己的类来实现IIdentity和IPrincipal。然后在global.asax的OnPostAuthenticate中分配它们。 谢谢。