I am trying to implement a custom role manager in an MVC5 application using the following Custom Role Provider Tutorial.
I have created my Custom Role Provider overiding the 2 required functions.
namespace Models.Security
{
public class CustomRoleProvider : RoleProvider
{
/// logic
public override string[] GetRolesForUser(string username)
{
/// logic
public override bool IsUserInRole(string username, string roleName)
{
I then need to alter my web config to use this new provider...
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<clear />
<add name="CustomRoleProvider" type="Models.Security.CustomRoleProvider"/>
</providers>
</roleManager>
However when I try and access my application I get the following error:
Parser Error Message: Could not load type 'Models.Security.CustomRoleProvider'.
Source Error:
Line 29: <providers>
Line 30: <clear />
Line 31: <add name="CustomRoleProvider" type="Models.Security.CustomRoleProvider"/>
Line 32: </providers>
Line 33: </roleManager>
As far as I am aware I have done everything that is required. The only thing that is different is I am using a custom membership linking to AD
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Account/Login" timeout="200" slidingExpiration="false" protection="All" />
</authentication>
<membership defaultProvider="ADMembershipProvider">
<providers>
<clear />
<add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
</providers>
</membership>
Is there something else I need to do? Has MVC5 changed the approach?