title: Displaying content dynamically based on user role
body: <p>My page hides content if the user isn't in a role that should see it.</p>
  
  <p>Currently I have 2 roles that can see this content: global and admin.</p>
  
  <p>If the user is in either of these roles, they should be able to see the content, but I'm having trouble working out the condition.</p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>// roles can be a single role ("global")
  // or it can be multiple roles ("global,admin")
  private bool CheckAllowed(string roles)
  {
      var user = HttpContext.Current.User;
      var allowed = false;
  
      if (roles.Contains(","))
      {
          string[] rolesArr = roles.Split(',');
  
          foreach (string r in rolesArr)
          {
              allowed = (user.IsInRole(r)) ? true : false;
          }
      }
      else
      {
          allowed = (user.IsInRole(r)) ? true : false;
      }
  
      return allowed;
  }
  </code></pre>
  
  <p>My issue is with the loop.</p>
  
  <p>If the user is in <code>rolesArr[0]</code> but not in <code>rolesArr[1]</code> then the loop will mark them <em>"not allowed"</em> and they won't see the content they need to as a member of <code>rolesArr[0]</code>.</p>
  
  <p>How can I track whether or not a user is allowed to view the role-specific content more accurately?</p>