title: .Net Membership in nTier App
body: <p>Lets say I have an ASP.Net MVC App and this app (UI) references a Business Logic Layer (BLL) and the BLL references my Data Access Layer (DAL).</p>
  
  <p>I am utilizing a Custom Membership and Role provider for Authorization.  </p>
  
  <p>I am trying to determine what layers need to reference my Membership provider.</p>
  
  <p>In MVC you can perform Authorization checks in the following manner:</p>
  
  <pre><code>[Authorize(Roles = "SomeRoleName")]
  public ActionResult Index()
  {
  //do something
  }
  </code></pre>
  
  <p>And in my BLL I may want to check to see if a User is in a Role as well:</p>
  
  <pre><code>public static bool IsRoleEditor(User user, Role userRole)
    {
     bool retValue = false;
  
     if (user.Application.AppID == UserRole.Application.AppID)
     {
          if (Roles.IsUserInRole("ModifyRoles"))
          {
             retValue = true;
          }
  
  
      return retValue;
     }
  </code></pre>
  
  <p>I would have to reference and instantiate the Membership classes in both layers if I do this.  Is this the correct way to architect an app like this?  Seems like a lot of redundancy.</p>
  
  <p>Since I have a BLL do I avoid using the "[Authorize(Roles = "SomeRoleName")]" attributes and instead call a BLL function from within the MVC code to check if the user is in a role?  If I do this the MVC still needs a reference to the membership provider for authentication and such anyway to take advantage of the Login and other ASP controls, right?</p>
  
  <p>Am I way off base and heading in the wrong direction?</p>