Ung*_*aro 9 razor entity-framework-6 asp.net-identity-3 asp.net-core
Visual Studio 2015脚手架使用UserManager<TUser>
不能用于创建的脚手架ClaimsIdentity
.有没有人有一个如何做到这一点的工作示例?
VS2015脚手架抛出错误:
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;
}
Run Code Online (Sandbox Code Playgroud)
注意:我添加了ApplicationUser
与之不冲突的属性IdentyUser
.
Nko*_*osi 12
UserManager在MVC6版本中已更改.您需要修改代码......
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) {
var authenticationType = "Put authentication type Here";
var userIdentity = new ClaimsIdentity(await manager.GetClaimsAsync(this), authenticationType);
// Add custom user claims here
return userIdentity;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1515 次 |
最近记录: |