title: CastleWindsor LifeStyle.PerWebRequest behaves like singleton
body: <p>I am trying to create a UserService that I can inject in my classes, that will hold the user currently logged in to my system. 
  I am using CastleWindsor as my container.</p>
  
  <p>Now my problem is that I am trying to make my UserService disposable, so that the databaseconnection fetching the user on  creating will also be disposed when the object is destroyed.</p>
  
  <p>I added the following setup in my Global.asax.cs:</p>
  
  <pre><code>private static void BootstrapContainer()
  {
      _container = new WindsorContainer().Install(FromAssembly.This());
  
      var controllerFactory = new WindsorControllerFactory(_container.Kernel);
      ControllerBuilder.Current.SetControllerFactory(controllerFactory);
  
      GlobalConfiguration.Configuration.DependencyResolver = new WindsorDependencyResolver(_container.Kernel);
  
      _container.Register(Component.For&lt;IUserService&gt;()
          .LifestylePerWebRequest()
          .ImplementedBy&lt;UserService&gt;());
  
      _container.Register(Component.For&lt;IPrincipal&gt;()
          .LifeStyle.PerWebRequest
          .UsingFactoryMethod(() =&gt; HttpContext.Current.User));
  }
  </code></pre>
  
  <p>Which is called in my <code>Application_Start</code>.</p>
  
  <p>My UserService code is as follows:</p>
  
  <pre><code>public interface IUserService
  {
      OrganisationBruger User { get; }
      int UserId { get; }
  }
  
  public class UserService : IUserService, IDisposable
  {
      private readonly IPrincipal _principal;
      private OrganisationBruger _user;
      private readonly DatabaseDataContext _db;
  
      public UserService(IPrincipal principal, IDatabaseDataContextFactory dataContextFactory)
      {
          _principal = principal;
          _db = dataContextFactory.GetDataContext();
      }
  
      public OrganisationBruger User =&gt; _user ?? (_user = GetUser());
      public int UserId =&gt; Convert.ToInt32(_principal.Identity.Name);
  
      private OrganisationBruger GetUser()
      {
          return _db.OrganisationBrugers.Single(u =&gt; u.ID == UserId);
      }
  
      public void Dispose()
      {
          _db.Dispose();
      }
  }
  </code></pre>
  
  <p>When I Debug my code I can see on the very first request I fire it correctly creates the class <code>UserService.cs</code> and then disposes it after the webrequest. Now my problem is the second web request does not seem to call the constructor anymore thus just reusing the formerly created object. This leads to the <code>DatabaseContext</code> already being disposed of. </p>
  
  <p>I thought that <code>LifestylePerWebRequest</code> meant that the <code>UserService</code> would get recreated on every request. Can anyone help me understand this?</p>