title: NHibernate with Autofac within ASP.NET (MVC): ITransaction
body: <p>What is the best approach to managing NHibernate transaction using Autofac within web application?</p>
  
  <p>My approach to session is</p>
  
  <pre><code>builder.Register(c =&gt; c.Resolve&lt;ISessionFactory&gt;().OpenSession())
         .ContainerScoped();
  </code></pre>
  
  <p>For <code>ITransaction</code>, I have <a href="http://code.google.com/p/autofac/source/browse/trunk/src/Example/Remember.Persistence.NHibernate" rel="noreferrer">found an example</a> on Google Code, but it relies on <code>HttpContext.Current.Error</code> when deciding whether to rollback.</p>
  
  <p>Is there a better solution? And what scope NHibernate transaction <strong>should</strong> have?</p>