title: Filter actions for userroles and building up a menu
body: <p>I am building up a MVC Razor (.Net) site for the company i work for. Yet i'm still very new to MVC and i was just wondering how to do this.
  Actually i have 2 questions but the first one is more important.</p>
  
  <p>And the logged in user is stored in the viewbag.
  The user has a value of an emum containing the user's role (Example: Client, Coach, Admin).
  How can i make filters on actions for custom roles e.g.</p>
  
  <pre><code>[Roles(Coach,Admin)]    
  public ActionResult Index(Somemodel model)
          {
              if (ModelState.IsValid)
              {
                  dosomestuff()
  
          }
          return View();
      }
  </code></pre>
  
  <p>Now secondly this is just for the lazy.
  Is it possible to generate menu items from filters
  And in addition to also give the roles for whom the menuitem should show up.</p>
  
  <p>Example:</p>
  
  <pre><code>[MenuItem]
  [Roles(Coach,Admin)]    
  public ActionResult Index(Somemodel model)
          {
              if (ModelState.IsValid)
              {
                  dosomestuff()
  
          }
          return View();
      }
  </code></pre>
  
  <p>Can i make a structure that This will automatically show up in some kind of menu for in this case only the Users that are marked as either coach or admin.</p>
  
  <p>Thanks for your help guys!</p>