title: Any way to use Authorization Policies in a view in .NET Core 1.0 MVC?
body: <p>I know in controllers, you can write <code>[Authorize("policyName")]</code> without an issue, but is there any way to use a policy in a view? I'd rather not use <code>User.IsInRole(...)</code> every single time I want to authorize some HTML.</p>
  
  <p>Edit:</p>
  
  <p>Here's some code</p>
  
  <p><strong>Startup.cs -- Policy Declaration</strong></p>
  
  <pre><code>    services.AddAuthorization(options =&gt;
      {
          options.AddPolicy("testPolicy", policy =&gt;
          {
              policy.RequireAuthenticatedUser()
                    .RequireRole("RoleOne", "RoleTwo", "RoleThree")
                    .RequireClaim(ClaimTypes.Email);
          });
      });
  </code></pre>
  
  <p><strong>Admin Controller</strong></p>
  
  <pre><code>[Authorize("testPolicy")]
  public class AdminController : Controller
  {
      public IActionResult Index()
      {
          return View();
      }
  }
  </code></pre>
  
  <p><strong>Navbar HTML</strong></p>
  
  <pre><code>&lt;div class="navbar navbar-inverse navbar-fixed-top"&gt;
              &lt;div class="container"&gt;
                  &lt;div class="navbar-collapse collapse"&gt;
                      &lt;ul class="nav navbar-nav"&gt;
                          &lt;li&gt;&lt;a asp-controller="Home" asp-action="Index"&gt;Home&lt;/a&gt;&lt;/li&gt; 
  
                          &lt;!-- I want to implement my policy here. --&gt;
                          @if (User.IsInRole("..."))
                          {
                              &lt;li&gt;&lt;a asp-controller="Admin" asp-action="Index"&gt;Admin&lt;/a&gt;&lt;/li&gt;
                          }
                      &lt;/ul&gt;
                      @await Html.PartialAsync("_LoginPartial")
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>