title: Can I Use Async to Perform Fire-and-Forget NHibernate Saves in an ASP.NET MVC Application?
body: <p>I have an ASP.NET MVC application that uses NHibernate to persist data into a SQL Server database.</p>
  
  <p>There are cases where I want to save an entry into a database (initially triggered by a call into an action method on a controller) but there's no need to block the caller.</p>
  
  <p>Is it "safe" to try to implement a fire-and-forget mechanism into the database that will put the database call into a Task and then invoke it on the background so control can return immediately to the caller?  (OR accomplish the same thing with BackgroundWorker or the "async/await" keywords)  I need a solution where NHibernate will not get tripped up by ASP.NET trying to clean up its ISession, which is per-request.  I'm using Autofac for lifetime management on the session.  I assume that the database operation would have a slightly longer lifetime than the web request itself, and I'm not sure how smoothly that would work.</p>