title: asp.net mvc custom attributes
body: <p>I am trying to create a custom attribute in mvc to use it's parameters in a view as breadCrumb.</p>
  
  <p>well, this is the code of the attribute</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
  public class BreadCrumbAttribute : Attribute {
  
      public BreadCrumbAttribute(string title, string parent, string url) {
          this._title = title;
          this._parent = parent;
          this._url = url;
      }
  
      #region named parameters properties
      private string _title;
      public string Title {
          get { return _title; }
      }
  
      private string _url;
      public string Url {
          get { return _url; }
      }
  
      private string _parent;
      public string Parent {
          get { return _parent; }
      }
      #endregion
  
      #region positional parameters properties
      public string Comments { get; set; }
      #endregion
  
  }
  </code></pre>
  
  <p>this is the call of the attribute</p>
  
  <pre><code>[BreadCrumbAttribute("tile", "parent name", "url")]
      public ActionResult Index() {
       //code goes here
       }
  </code></pre>
  
  <p>this is a way of how I'd like to get the values. (this is a partial view)</p>
  
  <pre><code>System.Reflection.MemberInfo inf = typeof(ProductsController);
  object[] attributes;
  attributes = inf.GetCustomAttributes(typeof(BreadCrumbAttribute), false);
  
  foreach (Object attribute in attributes) {
      var bca = (BreadCrumbAttribute)attribute;
      Response.Write(string.Format("{0}&gt;&lt;a href={1}&gt;{2}&lt;/a&gt;", bca.Parent, bca.Url, bca.Title));
  }    
  </code></pre>
  
  <p>Unfortunately, the attribute didn't get call with the way I implement it. Although, If I add the attribute in Class instead of an Action method it worked.
  How could I make it work?</p>
  
  <p>Thanks</p>