Giàn giáo Visual Studio 2015 sử dụng UserManager<TUser>
không thể sử dụng để tạo ClaimsIdentity
. Có ai có một ví dụ làm việc về cách làm điều này?Tạo danh tính xác nhận quyền sở hữu bằng Identity 3
Các giàn giáo VS2015 ném lỗi:
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;
}
N.B .: Tôi đã thêm tính để ApplicationUser
mà không mâu thuẫn với IdentyUser
.
Lỗi giàn giáo nào và ở đâu? Phương thức bạn đăng cho thấy rằng nó trả về 'ClaimsIdentity' – Nkosi
UserManager không chứa định nghĩa cho CreateIdentityAsync hoặc DefaultAuthenticationTypes –
Ungaro
Để tái tạo: VS2015 tạo một dự án web ASP.NET mới với mẫu MVC 6. Trong Mô hình trong ApplicationUser.cs, thêm tham chiếu đến System.Security.Claims và Micosoft.AspNet.Identity và chèn mã ở trên vào lớp ApplicationUser. Xem các lỗi được mô tả trong phần bình luận ở trên. – Ungaro