title: Castle Windsor 3 persists PerWebRequest objects across multiple web requests
body: <p>I have an MVC 4 project and am trying to inject a PerWebRequest object into my controller. However it appears the object is not being recreated across multiple requests</p>
  
  <pre><code> private static IWindsorContainer InitializeWindsor()
      {
          var container = new WindsorContainer().Install(FromAssembly.This());
  
          // Add Factory facility
          container.AddFacility&lt;TypedFactoryFacility&gt;();
  
          // Register all controllers from this assembly
          foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
          {
              container.Register(
                  AllTypes.FromAssembly(assembly).BasedOn&lt;Controller&gt;().Configure(c =&gt; c.LifestyleTransient())
                  );
          }
  
          // Register HTTP Handlers
          container.Register(Component.For&lt;HttpRequestBase&gt;().LifeStyle.PerWebRequest.UsingFactoryMethod(() =&gt; new HttpRequestWrapper(HttpContext.Current.Request)));
          container.Register(Component.For&lt;HttpContextBase&gt;().LifeStyle.PerWebRequest.UsingFactoryMethod(() =&gt; new HttpContextWrapper(HttpContext.Current)));
  
  
          // Register components
          container.Register(Component.For&lt;PerWebRequestObject&gt;().LifeStyle.PerWebRequest);
  }
  </code></pre>
  
  <p>Here's my PerWebRequestObject:</p>
  
  <pre><code>public class PerWebRequestObject
  {
      public DateTime DateCreated { get; set; }
  
      public PerWebRequestObject()
      {
          DateCreated = DateTime.UtcNow;
          Debug.WriteLine("Created: " + DateCreated.ToLongTimeString());
      }
  }
  </code></pre>
  
  <p>Here's my TestController:</p>
  
  <pre><code>public class TestController : BaseController
  {
      public PerWebRequestObject pwrObject { get; set; }
  
      public ActionResult Test()
      {
          Debug.WriteLine(pwrObject.DateCreated.ToLongTimeString());
          return new ContentResult();
      }
  }
  </code></pre>
  
  <p>Why is this not working? Note that I'm using the WindsorControllerFactory and releasing the Controller like so:</p>
  
  <pre><code>    public override void ReleaseController(IController controller)
      {
          var disposableController = controller as IDisposable;
          if (disposableController != null)
              disposableController.Dispose();
  
          _windsorContainer.Release(controller);
      }
  </code></pre>