Edit: By Overriding the RoleProvider we were hoping to still use the same methods with our new methods. Such as Roles.GetRolesForUser(int).
string[] myRoles3 = ((PortalRoleProvider) (Roles.Provider)).GetRolesForUser(2);
That above code seems a bit excessive ?
I have a class which overrides some members of the RoleProvider and adds new methods. Eg.
public string[] GetRolesForUser(int UserId)
{
IEnumerable<Role> RoleList = _Repo.GetRolesForUser(UserId);
string[] RetVal = new string[] {};
foreach (var curRole in RoleList)
{
RetVal[RetVal.GetUpperBound(0)] = curRole.RoleName;
}
return RetVal;
}
Now when I am in the logic of my code I want to write Roles.GetRolesForUser(2) but when i type this, it does seem to see the extra method that I have added. Here is the class declaration and the webconfig.
namespace PortalMVC.Providers
{
public class PortalRoleProvider : RoleProvider
{
Web.config
<roleManager enabled="true" defaultProvider="PortalRoleProvider">
<providers>
<clear/>
<add name="PortalRoleProvider" type="PortalMVC.Providers.PortalRoleProvider"/>
</providers>
</roleManager>
Any suggestions why this is?