title: How can I implement a security trimmed Html.RenderAction?
body: <p>I am looking to create a security trimmed (basically if you don't have permission don't render) Html.RenderAction.</p>
  
  <p>The aim is to display various widgets/page components and if the person doesn't have permission on the action the RenderAction doesn't get called (or at least doesn't cause a re-direct to login page). For example the page is shown to all logged in users. However there will be parts that are only for HR, Business Development and if you are in HR and Business development you would get both parts etc.</p>
  
  <p>Each part called by RenderAction is stand-alone so it means I can easily make pages that contain all the required parts but then they just don't display if the user isn't permitted. If I call RenderAction on for an action someone doesn't have permission to then it causes them to get re-directed to login page. </p>
  
  <p>I have seen something similar done with links but as anyone done anything similar for Actions?</p>
  
  <p>I was hoping to get something like:</p>
  
  <pre><code>@Html.RenderSecurityTrimmedAction("Main","Business-Widget1")
  @Html.RenderSecurityTrimmedAction("Main","HR-Widget")
  @Html.RenderSecurityTrimmedAction("Main","General-Widget3")
  </code></pre>
  
  <p>Where Widget access is based on the persons current role. I have security access working perfectly. It's mainly creating a RenderAction that doesn't uncenssarily run the Action if the user doesn't have perission</p>
  
  <p>I want to keep the code DRY so I don't want to be carrying lots of ViewModel properties and then having to wrap every Html.RenderAction in an if statement. These components will appear in a variety of places so I want  them to be plug and play.</p>