title: Pass an object from ActionFilter.OnActionExecuting() to an ApiController
body: <p>I wish to create an object per http request within an ActionFilter and pass this object to the controller. So far I have tried Request.Properties[] like the following</p>
  
  <pre><code>public class DbReadonlyAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuting(HttpActionContext actionContext)
      {
          actionContext.Request.Properties["CustomObjectKey"] = new MyClass();
  </code></pre>
  
  <p>And I have also tried to assign the new object direct to a ControllerBase class.</p>
  
  <pre><code>public class DbReadonlyAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuting(HttpActionContext actionContext)
      {
          var controller = (MyControllerBase) actionContext.ControllerContext.Controller;
          controller.StorageContextFactory = new MyClass();
  </code></pre>
  
  <p>The problem is that neither technique delivers an instance of MyClass to the controller because the new Property["CustomObjectKey"] is lost in the Webapi pipeline by the time a controller method is invoked.</p>
  
  <p>The controller is re-instantiated by the webapi pipeline after the call to action filter OnActionExecuting().</p>
  
  <p>Break points confirm the Webapi pipeline schedules the following event flow during a single http request.</p>
  
  <ul>
  <li>constructor MyControllerBase()</li>
  <li>MyAuthenticationFilter</li>
  <li>Filter OnActionExecuting()</li>
  <li>constructor MyControllerBase()</li>
  <li>MyController.MethodA()</li>
  </ul>
  
  <p>The double instantiation of MyControler is odd, but right now I am looking for any technique to pass a newly created object from an action filter to a controller.</p>
  
  <p>Edit-1: The MyAuthorizationFilter mentioned in v1 of this question is actually an Authentication filter. Still investigating.</p>
  
  <p>Solution: The bug was in another filter. After I removed my authentication filter the problem reported in this question went away.</p>