SOLVED:the method public override string[] GetRolesForUser(string username) was erroneously returning null as the first item of the array.All good now.
I am trying to implement custom role and membership providers for my application but not having luck with role provider. In one of my controller’s method, if I have [Authorize] directive it works fine but when I want to have role based authorization by adding [Authorize(Roles = "Admin")] it gives an error saying ‘Key cannot be null. Parameter name: key’ .
I think there is something wrong with the entires in web.config file but cannot find what it is. The modified entries in web.config file look like
<membership defaultProvider="CustomMembershipProvider">
<providers>
<clear />
<add name="CustomMembershipProvider" type="eLibrary.Models.CustomMembershipProvider" connectionStringName="AppDb" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="CustomRoleProvider" enabled="true" cacheRolesInCookie="true" >
<providers>
<clear/>
<add name="CustomRoleProvider" type="eLibrary.Models.CustomRoleProvider" />
</providers>
</roleManager>
It would be great if anyone can throw some lights on.
SOLVED:the method public override string[] GetRolesForUser(string username) was erroneously returning null as the first item of the array.All good now.