I wanted to make my Controller methods register as [HttpGet] if they have "get" in the method name, the same goes for [HttpPost] if they have "create" etc.
How can I create an "attributeAssigner", that would go over the assembly and do the job?
I wanted to make my Controller methods register as [HttpGet] if they have "get" in the method name, the same goes for [HttpPost] if they have "create" etc.
How can I create an "attributeAssigner", that would go over the assembly and do the job?
In fact you can't. The example Ygalbel mentioned is a solution which, to my opinion is kind of cheat.
The code in the example creates another class (a proxy) which inherits from the class you want to apply the attribute(s) to. In fact, if you use reflection to retrieve the custom attributes decorating your class (its properties and methods) you'll find none of them. The instance of a class in the suggested solution is instance of another class, not yours!
I'm not 100% sure, but I can guess ASP.NET (Core) does exactly this, so it'll find no attributes decorating your controller's actions.
In order to use the suggested solution you'll need to write some code which will have to do the following:
Maybe this text could be a good starting point but still, your idea needs to be clarified.
Anyway, if you do insist on its implementation I wish you good luck. This is part of the advanced topics in ASP.NET Core.
HTH