title: ActionFilterAttribute on Controller vs action method
body: <p>I have a <code>LoggingAttribute</code> which logs request and response in <code>OnActionExecuted</code> method:</p>
  
  <pre><code>public class LoggingAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuted(HttpActionExecutedContext httpContext)
      {
              //Logger.Log();
      }
  }
  </code></pre>
  
  <p>There is another attribute for validating the request and return <code>BadRequest</code>. This return response from <code>OnActionExecuting</code> method:</p>
  
  <pre><code>public class ValidateModelAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuting(HttpActionContext actionContext)
      {
          var modelState = actionContext.ModelState;
          if (!modelState.IsValid)
          {
              actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, modelState);
          }
      }
  }
  </code></pre>
  
  <p>Now, when I apply both these attributes on Action method, my <code>BadRequest</code>s are not being logged but when I apply <code>LoggingAttribute</code> on controller level and <code>ValidateModelAttribute</code> on action method, <code>BadRequest</code>s are getting logged (<code>OnActionExecuted</code> of <code>LoggingAttribute</code> getting called).</p>
  
  <p>Can someone please explain this behaviour i.e. <code>OnActionExecuted</code> getting called even when action method is not being executed when attribute applied at controller.</p>