【问题标题】:No ApplicationRoleManager class in my MVC 5 Identity 2 project我的 MVC 5 Identity 2 项目中没有 ApplicationRoleManager 类
【发布时间】:2025-12-04 13:35:01
【问题描述】:

我正在尝试使用 VS 2013 Update 2 在项目中实现角色。项目本身是带有 Identity 2.0 的 MVC 5...开箱即用的标准 Web 模板。然而,在浏览在线教程时,我不断看到它们引用了 ApplicationRoleManager 类。这个类在我的项目中默认没有定义,有人知道为什么吗?或者如何解决?

更新 同样在我的 App_Start 文件夹下的 IdentityConfig.cs 类中,包含的唯一类是: .ApplicationUserManager .电子邮件服务 .SmsService

【问题讨论】:

  • 我真的是 asp.net 的新手,但据我所知,这可能是 Identity 2.0 和 2.1 之间更改的功能

标签: asp.net-mvc identity


【解决方案1】:

它似乎是 VS 中 mvc 模板版本之一的一部分,但它只是 RoleManager 的快捷方式

public class ApplicationRoleManager : RoleManager<IdentityRole>
{
    public ApplicationRoleManager(IRoleStore<IdentityRole,string> roleStore)
        : base(roleStore)
    {
    }
}

【讨论】: