ori*_*uig 5 c# asp.net-mvc identity claims owin
几天前,我发现 Ben Foster 写的一篇关于 MVC、Identity 和 OWIN 的非常好的教程。教程在这里
我刚刚完成本教程,在尝试重写函数“CreateAsync”时发现了一个问题。Visual Studio 不允许这样做。
这是代码:
public class AppUserClaimsIdentityFactory : ClaimsIdentityFactory<AppUser>
{
public override async Task<ClaimsIdentity> CreateAsync(
UserManager<AppUser> manager,
AppUser user,
string authenticationType)
{
var identity = await base.CreateAsync(manager, user, authenticationType);
identity.AddClaim(new Claim(ClaimTypes.Country, user.Country));
return identity;
}
}
Run Code Online (Sandbox Code Playgroud)
有人知道我该如何解决这个问题吗?
解决方案
感谢@ETorre,这就是最终的代码!
public class AppUserClaimsIdentityFactory : ClaimsIdentityFactory<AppUser, string>
{
public async override Task<ClaimsIdentity> CreateAsync(UserManager<AppUser, string> manager,
AppUser user, string authenticationType)
{
var identity = await base.CreateAsync(manager, user, authenticationType);
identity.AddClaim(new Claim(ClaimTypes.Country, user.Country));
return identity;
}
}
Run Code Online (Sandbox Code Playgroud)
你可以试试看看版本?git 上的文件使用 Microsoft.AspNet.Identity.Core.dll 版本 1,现在是版本 2。尝试 innerit of ClaimsIdentityFactory
| 归档时间: |
|
| 查看次数: |
3683 次 |
| 最近记录: |