this question has answer here:
i want build custom filter attribute added controller level. how can current controller, action , parameter names being invoked?
example: if issues post request to: https://localhost:443/api/users/delete/3
how can in attribute (and not talking url parsing here)
- controller = users
- action = delete
- id = 3
@kamo has provided duplicate question first parts, id, use .actionarguments
, eg:
public override void onactionexecuting(httpactioncontext actioncontext) { var id = (int)actioncontext.actionarguments["id"];
actionarguments dictionary, iterate using linq if arg optional or writing generic handler actions (eg log every action parameters/arguments)
this provided framework, after binding, match action's parameters - if binding not match action filterabbtribute won't kick in if applied @ controller level. can't use finding why routes don't match actions.
Comments
Post a Comment