【发布时间】:2015-02-02 02:11:37
【问题描述】:
如何在我的 MVC4 应用程序中启用角色管理器? 我需要为我的应用程序用户添加角色,并且我需要一个关于如何正确执行此操作的摘要。
【问题讨论】:
标签: c# asp.net-mvc-4 web-applications configuration role-manager
如何在我的 MVC4 应用程序中启用角色管理器? 我需要为我的应用程序用户添加角色,并且我需要一个关于如何正确执行此操作的摘要。
【问题讨论】:
标签: c# asp.net-mvc-4 web-applications configuration role-manager
这是我需要的,希望能帮助一些人。
要启用角色管理器,需要在web.Config文件中添加相应的标签,不要忘记更改enable="tru" 在角色管理器标签中隐含
您可以在以下位置找到您的 ASP.Net 应用程序的这些标签: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config 文件
<membership>
<providers>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
【讨论】: