asp.net mvc - Can I add a custom attribute to a controller method without writing a filter? -


I would like to add attributes to my controller methods, which can be inspected by reflection.

I can see how it can write a filter, and I will write an empty filter, if it is the only way to get me, but I really want to be a reflection-visible The feature that can be used to generate documentation. Example:

  [Operator Friend Description ("Start a new message from a letter template and set the initial property.")] Create public actions (string editor name, int mastki, ...) (Alternatively, is there any other approach or documentation feature that will allow me to set the operator's favorable name for personal controller methods and retrieve it with reflection?)    

/ P>

There is no magic method that you can use without defining the operator preferred description But if it does not require filter functionality, then do not get it from FilterAttribute .

If you declare MVC FilterAttribute , you will see that this is just a special System.Attribute .

  Public abstract class FilterAttribute: attribute, IMvcFilter   

We can verify the basis for all the attributes System.Attribute . Since you do not have any special functionality, get it from it instead.

An example attribute in C #

  public class arbitrage: attribute {public string arbitrageata {get; Private set; } Public Arbitrage (String Unauthorized) {ArbriardData = Manmandidae; }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -