title: MVC 3 Call Controller method directly but also invoke the ActionFilterAttribute?
body: <p>How would you go about invoking the ActionFilterAttribute when you are calling a controllers method directly? Imagine the following:</p>
  
  <pre><code>public class ApiController : Controller {
  
      public ActionResult CallSomething() {
           return IsCalled();
      }
  
      [MyAction]
      public ActionResult IsCalled() {
           return View();
      }
  }
  </code></pre>
  
  <p>So the request comes into <code>/Api/CallSomething</code>, the CallSomething() method internally calls another method (in this case IsCalled()) but when that method is called the ActionFilterAttribute is invoked and runs.</p>
  
  <p>At the moment the ActionFilterAttribute will only be invoked if it's part of the original request, which makes sense because then it's part of the whole MVC lifecycle and all I'm doing is just calling a method directly, I'd need to do a RedirectToAction if I wanted it to get fired by MVC. RedirectToAction alters the URL so this isn't suitable for my purposes.</p>
  
  <p>I've poked about the System.Web.Mvc code but I can't see how or when its being invoked. I figure that if it can do it then so can I potentially using reflection. In this event the Views aren't relevant as I am override the ExecuteResult() to write my own content into the http response.</p>
  
  <p>Anyway I've resigned myself to this maybe not being possible but I'd just thought it would be worth a try.</p>