title: Override Role Provider - ASP.NET
body: <p>Edit: By Overriding the RoleProvider we were hoping to still use the same methods with our new methods. Such as Roles.GetRolesForUser(int).</p>
  
  <pre><code> string[] myRoles3 = ((PortalRoleProvider) (Roles.Provider)).GetRolesForUser(2);
  </code></pre>
  
  <p>That above code seems a bit excessive ? </p>
  
  <p>I have a class which overrides some members of the RoleProvider and adds new methods. Eg.</p>
  
  <pre><code> public string[] GetRolesForUser(int UserId)
      {
          IEnumerable&lt;Role&gt; RoleList = _Repo.GetRolesForUser(UserId);
  
  
          string[] RetVal = new string[] {};
  
          foreach (var curRole in RoleList)
          {
              RetVal[RetVal.GetUpperBound(0)] = curRole.RoleName;
          }
          return RetVal;
      }
  </code></pre>
  
  <p>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.</p>
  
  <pre><code> namespace PortalMVC.Providers
   {
      public class PortalRoleProvider : RoleProvider
      {
  </code></pre>
  
  <p>Web.config</p>
  
  <pre><code>&lt;roleManager enabled="true" defaultProvider="PortalRoleProvider"&gt;
      &lt;providers&gt;
          &lt;clear/&gt;
           &lt;add name="PortalRoleProvider" type="PortalMVC.Providers.PortalRoleProvider"/&gt;
      &lt;/providers&gt;
  &lt;/roleManager&gt;
  </code></pre>
  
  <p>Any suggestions why this is?</p>