ASP.NET MVC: Call one controller action from another, with ActionFilters applied -
take @ code below.
when get()
calls foobar()
, foobaz()
, actionfilter
s decorate foobar()
, foobaz()
not invoked.
how can call these other 2 controller actions within get()
in way causes someaction
, anotheraction
filters execute?
public class features : controller { [someaction] public bool foobar(string id = null) { return true; } [anotheraction] public bool foobaz() { return false; } public jsonresult get() { return this.jsonresult(new dictionary<string, bool>() { { "foobar", this.foobar() }, { "foobaz", this.foobaz() } }); } }
controller actions aren't meant used methods. in order them function must called within request cycle. perhaps example simplistic, looks you're trying use these "actions" standard methods. while controller can technically have method that's never meant exposed route, it's not idea sort of thing. move logic off model or helper class.
Comments
Post a Comment