title: Get list of custom attributes for current action/controller in ASP.NET MVC
body: <p>Checking out the sample code from <a href="http://lukesampson.com/post/471548689/entering-and-exiting-https-with-asp-net-mvc" rel="noreferrer">http://lukesampson.com/post/471548689/entering-and-exiting-https-with-asp-net-mvc</a> written for ASP.NET MVC2, I noticed they can check if a custom attribute is applied to the current action or controller by accessing <code>filterContext.ActionDescriptor</code> and <code>filterContext.ActionDescriptor.ControllerDescriptor</code> respectively:</p>
  
  <pre><code>public class ExitHttpsIfNotRequiredAttribute : FilterAttribute, IAuthorizationFilter {
      public void OnAuthorization(AuthorizationContext filterContext) {
          // snip
  
          // abort if a [RequireHttps] attribute is applied to controller or action
          if(filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(RequireHttpsAttribute), true).Length &gt; 0) return;
          if(filterContext.ActionDescriptor.GetCustomAttributes(typeof(RequireHttpsAttribute), true).Length &gt; 0) return;
  
          // snip
      }
  }
  </code></pre>
  
  <p>What would be the ASP.NET MVC 1 method of checking the action and controller for a custom attribute? In ASP.NET MVC 1 there is no <code>filterContext.ActionDescriptor</code> that I can tell.</p>