title: ASP.NET / MVC.NET tag for checking roles (equivalent of declarative attribute PrincipalPermission)
body: <p>I use declarative roles in my MVC.NET controllers and I have a custom membership &amp; roles provider.</p>
  
  <p>This works fine:</p>
  
  <pre><code> [Authorize(Roles = "ADMIN")]
  </code></pre>
  
  <p>Also, I have a base MVC.NET CustomController class that all controllers derive from, and it has a "currentUser" property that is auto-fetched from the session on demand, so all controller code just refers to "currentUser" and doesn't worry about sessions, httpcontext, etc. I've implemented the membership provider properly, as it works with other parts of the framework that just deals with providers, but until now I had not tried to access the "User" principal from a view.</p>
  
  <p>What is the simplest syntax for check roles in a view page? I know I can use a helper to generate a partial view but I don't want that here, I want to explicitly wrap some sections of a page in some role checks.</p>
  
  <p>Something like this:</p>
  
  <pre><code>&lt;% if(currentUser.IsInRole("ADMIN") { %&gt;
  ...
  &lt;% } %&gt;
  </code></pre>
  
  <p>Thanks.</p>