title: IsUserInRole not working in CSHTML
body: <p>I have this code, but I don't know why this is not working properly.  I have a custom role provider created.</p>
  
  <pre><code>@if (Roles.IsUserInRole(User.Identity.Name, "Manager"))
  {
      &lt;li&gt;@Html.ActionLink("User Management", "Index", "User")&lt;/li&gt;
  }
  </code></pre>
  
  <p>This is the custom code, the rest wasn't modified.</p>
  
  <pre><code>   public override bool IsUserInRole(string username, string roleName)
      {      
          UserRoleType usrt = (from usr in db.Users
                     join usrRole in db.UserRoles on usr.UserID equals usrRole.UserID
                     where usr.Email == username
                     select usrRole.UserRoleType).FirstOrDefault();
  
          if (roleName.Split(',').Contains(usrt.UserRoleTypeName))
              return true;
  
          return false;
      }
  </code></pre>
  
  <p>This does work when I do this:</p>
  
  <pre><code>UserRoleProvider roleProvider = System.Web.Security.Roles.Provider as UserRoleProvider;
  
  if (roleProvider.IsUserInRole(httpContext.User.Identity.Name, Roles) || String.IsNullOrEmpty(Roles))
              return true;
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>    public override string[] GetRolesForUser(string roleName)
      {
          return db.UserRoleTypes.Select(u =&gt; u.UserRoleTypeName).ToArray();
  
      }
  </code></pre>