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

Popular posts from this blog

visual studio - vb.net filter binding source by time -

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -