title: Custom Role Provider has issue with AuthorizeAttribute for MVC
body: <p>I am developing a MVC 5 application with custom role provider, but it seems that the AuthorizeAttribute never call my customer role provider,  my code is as below:</p>
  
  <p>My Customer provider:</p>
  
  <pre><code>namespace MyDomain
  {
      public class CustomRoleProvider : RoleProvider
      {
           public override string[] GetRolesForUser(string username)
          {
              using (MyContext objContext = new MyContext())
              {
                  var objUser = objContext.Users.FirstOrDefault(x =&gt; x.Username == username);
                  if (objUser == null)
                  {
                      return null;
                  }
                  else
                  {
                      string[] ret = { objUser.Access_Levels.Name };
                      return ret;
                  }
              }
          }
  
          public override bool IsUserInRole(string username, string roleName)
          {
              var userRoles = GetRolesForUser(username);
              return userRoles.Contains(roleName);
          }
  }
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>[Authorize(Roles = "Administrator")]
  public class AdminController : Controller
  </code></pre>
  
  <p>And Web.Config:</p>
  
  <pre><code> &lt;system.web&gt;
      &lt;roleManager defaultProvider="CustomRoleProvider" enabled="true" &gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="CustomRoleProvider" type="Online_Storage_Portal.CustomRoleProvider"  cacheTimeoutInMinutes="30"/&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
    &lt;/system.web&gt;
  </code></pre>
  
  <p>Also my custom role provider is in the same project as my other controllers, I am able to call my custom role provider method with following code within my controller</p>
  
  <p>String[] roles = Roles.GetRolesForUser(username)</p>
  
  <p>but the controller with [Authorize(Roles = "Administrator")] always redirect the page to login screen even the user login and role are both valued.</p>
  
  <p>Please help!!</p>