Mar*_*one 5 asp.net-core-mvc asp.net-identity-3
我目前正在尝试向已通过身份验证的用户公开字段,但是在向已通过身份验证的用户添加新声明时遇到了一些困难。
在MVC5中,我将执行以下操作:
public class ApplicationUser : IdentityUser
{
public string FullName { 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
userIdentity.AddClaim(new Claim("FullName", FullName));
return userIdentity;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在MVC6中执行此操作时,遇到了对象和方法丢失的问题。Visual Studio表示CreateIdentityAsync()和DefaultAuthenticationTypes似乎都丢失了,当我深入研究Identity来源时,我可以看到CreateIdentityAsync不再存在,但是我似乎找不到关于DefaultAuthenticationTypes的任何信息。
目前,我认为这是一个不错的选择,但是过去几天让我发疯了,并且很高兴了解出了什么问题或这是如何改变的。
| 归档时间: |
|
| 查看次数: |
1054 次 |
| 最近记录: |