title: How to implement custom role based authorization in ASP.Net MVC
body: <p>I am working on a project where we are using Amazon SimpleDB as a data storage. In this application user can create roles at run time. While creating role, user can give Read/Write/Update permission for specific feature.</p>
  
  <p>The code I have tried;</p>
  
  <pre><code>using System;
  using System.Web.Http;
  using System.Web.Http.Controllers;
  using System.Web.Http.Filters;
  
  
  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
      public class MyAuthorization : ActionFilterAttribute
      {
          public string Model { get; set; }
          public string Action { get; set; }
  
          public override void OnActionExecuting(HttpActionContext filterContext)
          {
              //My code will go here
              base.OnActionExecuting(filterContext);
          }
      }
  </code></pre>
  
  <p>In Web API controller I have written as;</p>
  
  <pre><code>// GET api/values
          [MyAuthorization(Action = "Edit", Model = "Rack")]
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { "value1", "value2" };
          }
  </code></pre>
  
  <p>Now in OnActionExecuting, I want to fetch Action and Model attributes which I have specified over action method in APIController.</p>
  
  <p>How to handle it through code, since role names and rights are not known at design time.</p>