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; }
解决方法
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; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。