title: MVC4 role based controller's action access
body: <p>I want to build a Registration system where, while adding an user u can select the type of role you can give to him/her. And depending upon the role he/she it would be decided whether certain action in controller can be accessed or not. </p>
  
  <p>For example, let's say there are two roles, admin and developer.
  And having something like mentioned below would only allow user with roles as admin to acces following action.</p>
  
  <pre><code>[Authorize(Roles = "admin"]
  public ActionResult CreateUser()
  {
     return View();
  }
  </code></pre>
  
  <p>As far as I know I have to implement my custom <code>RoleProvider</code> or <code>IPrincipal</code>?
  I tried to find some example on that but didn't quite get what i'm exactly looking for.
  Here is how my RegisterModel currently looks like</p>
  
  <pre><code>public class RegisterModel
      {
          [Key]
          public Guid Id;
          [Required]
          [Display(Name="First Name")]
          public string FirstName {get; set;}
  
          [Required]
          [Display(Name="Last Name")]
          public string LastName {get; set;}
  
          [Required]
          [Display(Name="Email Id")]
          [DataType(DataType.EmailAddress)]
          public string EmailId {get; set;}
  
          [Required]
          [Display(Name = "User name")]
          public string UserName { get; set; }
  
          [Required]
          [Display(Name = "Password")]
          [DataType(DataType.Password)]
          public string Password { get; set; }
  
          [Required]
          [Display(Name = "Confirm Password")]
          [DataType(DataType.Password)]
          public string ConfirmPassword { get; set; }
  
         [Required]
         [Display(Name = "Role")]
         public UserRole Role { get; set; }
  
      }
  
  
  
    public class UserRole
      {
          [Key]
          public int RoleId { get; set; }
  
          public string RoleName { get; set; }
      }
  </code></pre>
  
  <p>Thing is I want the role to be decided when adding a user and use the Custom Authorize attribute. Any article or blog that anyone knows that can solve my issue? Or any suggestions, how to do it?</p>