c# - How can I find the decorated method from within a custom attribute? -
i need custom authorization based on specific methods in controllers. possible custom attribute know method being called?
given following:
[customattribute] public actionresult index() { //some stuff } is possible [customattribute] know index called specifically? same apply other method decorated [customattribute].
in mvc controller methods called actions.
you can figure out action has been called inside attribute having attribute inherit actionfilterattribute. override onactionexecuting method (or onactionexecuted). filtercontext (actionexecutingcontext) argument has property called actiondescriptor. can action name actionname property.
var actionname = filtercontext.actiondescriptor.actionname
Comments
Post a Comment