【发布时间】:2023-03-23 03:35:01
【问题描述】:
我正在通过 RavenDB 实现 ASP.NET Identity 并尝试向我的用户添加角色。 https://github.com/ILMServices/RavenDB.AspNet.Identity/blob/master/RavenDB.AspNet.Identity/UserStore.cs
此实现具有以下可用重载public Task AddToRoleAsync(TUser user, string role)
ApplicationUserManager 派生自 UserManager 但我无法达到过载。唯一可用的方法是基本方法AddToRoleAsync(string UserId, string role)。
Store 属性是 UserManager 基类中的公共属性,因此看起来并没有什么特别之处。
我也尝试直接调用manager.Store.AddToRoleAsync,但我再次没有通过智能感知恢复重载方法。
我希望有人能指引我正确的方向,真的卡在这里。
然后我的控制器当然继承了这个问题,这开始了我对为什么会发生这种情况的搜索。
针对 CodeNotFound,这里是 ApplicationUser。这很简单。
public class ApplicationUser : IdentityUser, IEntity
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { 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
return userIdentity;
}
}
【问题讨论】:
-
可以给我们看看你的ApplicationUser的代码吗?
-
我将课程添加到我的初始帖子中
标签: c# asp.net asp.net-mvc asp.net-identity ravendb