title: Authorizing sections of a view in MVC
body: <p>I was wondering if it's possible to authorize parts of a view inside the view.</p>
  
  <p>For example, I understand how to authorize the entire controller in this method</p>
  
  <pre><code>&lt;HandleError()&gt; _
  Public Class HomeController
    Inherits System.Web.Mvc.Controller
  
    Function Index()
      Return View()
    End Function
  
    &lt;Authorize(Roles:="Administrators")&gt; _
    Function AdministratorSecrets()
      Return View()
    End Function
  
  End Class
  </code></pre>
  
  <p>But what Id like to do is have it so if the admin is logged in, they can see additional links in my navigation.</p>
  
  <p>Something along the lines of</p>
  
  <pre><code>            &lt;ul id="menu"&gt;              
                  &lt;li&gt;&lt;%= Html.ActionLink("Home", "Index", "Home")%&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;%= Html.ActionLink("About", "About", "Home")%&gt;&lt;/li&gt;
                  &lt;Authorize(Roles:="Administrators")&gt; _
                  &lt;li&gt;&lt;%= Html.ActionLink("Admin", "Admin", "Home")%&gt;&lt;/li&gt;
              &lt;/ul&gt;
  </code></pre>
  
  <p>Obviously that won't work, but it gives an idea of what I'm trying to accomplish.</p>
  
  <p>Any ideas?</p>