title: Castle Windsor/NHibernate/FactoryMethod and registering an NHIbernate EmptyInterceptor
body: <p>I am using Castle Windsor for my IoC along with NHIbernate in an ASP.NET MVC app. It works great registered as follows:</p>
  
  <pre><code>container.Register(Component.For&lt;ISessionFactoryBuilder.().ImplementedBy&lt;SessionFactoryBuilder&gt;().LifestyleSingleton());
  
  // Register the NHibernate session factory as a singleton using custom SessionFactoryBuilder.BuildSessionFactory method.
  container.Register(Component.For&lt;ISessionFactory&gt;().UsingFactoryMethod(k =&gt; k.Resolve&lt;ISessionFactoryBuilder&gt;().BuildSessionFactory("ApplicationServices")).LifestyleSingleton());
  
  container.Register(Component.For&lt;ISession&gt;().UsingFactoryMethod(k =&gt; k.Resolve&lt;ISessionFactory&gt;().OpenSession()).LifestylePerWebRequest()); 
  </code></pre>
  
  <p>However, I want to introduce an NHibernate IInterceptor in order to provide easy auditing. Typically I've used a NHibernate session manager in which it's easy to pass in an interceptor later on because SessionFactory.OpenSession(...) would typically be called in Begin_Request as opposed to "sort of" during component registration (which is in App_Start). Unfortunately, the LifestylePerWebRequest module can't be accessed at that point so for i.e., the following understandably fails:</p>
  
  <pre><code>container.Register(Component.For&lt;IInterceptor&gt;().ImplementedBy&lt;ChangeAuditInfoInterceptor&gt;().LifestylePerWebRequest());
  var interceptor = container.Resolve&lt;IInterceptor&gt;();
          container.Register(Component.For&lt;ISession&gt;().UsingFactoryMethod(k =&gt; k.Resolve&lt;ISessionFactory&gt;().OpenSession(interceptor)).LifestylePerWebRequest()); 
  </code></pre>
  
  <p>What would be the best way to introduce an NHibernate Interceptor (which is usually inserted in SessionFactory.OpenSession(IInterceptor) when using this approach to NHibernate session management with Castle Windsor?</p>