【发布时间】:2016-06-24 17:12:10
【问题描述】:
我有一个 MVC 项目,允许我的用户将用户和角色添加到 AspNetRoles 和 AspNetUsers 表中。该应用程序使用 Active Directory 对登录视图上的用户进行身份验证。在我的数据库中,我已将用户user123 添加到我的数据库中Administrators 的角色中。我添加了以下逻辑,以使此链接对我的部分登录中的Administrators 角色可见。
@if (Roles.IsUserInRole("Administrators"))
{
@Html.ActionLink("Manage Accounts", "Index", "Roles")
}
我还将它添加到我的 web.config 以尝试实例化角色提供程序与数据库的连接。
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="DefaultConnection"
name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
applicationName="MyApplicationName" />
</providers>
</roleManager>
但是,user123 仍然看不到我的链接,根据我的数据库,Administrators 的成员。这是什么原因?
【问题讨论】:
标签: asp.net-mvc asp.net-identity asp.net-roles