title: Cannot access a disposed object.\r\nObject name: 'DataContext accessed after Dispose'
body: <p>I am using StructureMap.WebApi2 nuget package for Web API 2 project for managing the depedency injection. 
  In the DefaultRegistry.cs class I have mentioned all the dependencies required
  Nested container is used for each request.</p>
  
  <pre><code>For&lt;IScoreRepository&gt;().Use&lt;ScoreRepository&gt;();
   For&lt;IExternalUsersAuditRepository&gt;().Use&lt;ExternalUsersAuditRepository&gt;();
   For&lt;ITestScanService&gt;().Use&lt;TestScanService&gt;();
  
  
   // hook up specific questionnaire datacontext
   For&lt;SportsDataContext&gt;().LifecycleIs(new HttpContextLifecycle())
     .Use(c =&gt; new SportsDataContext(
       ConfigurationManager.ConnectionStrings["Database"].ConnectionString));
  
  // hook up datacontext for data and services
  For&lt;QuestionDataContext&gt;().LifecycleIs(new HttpContextLifecycle())
    .Use(c =&gt; new QuestionDataContext(
       ConfigurationManager.ConnectionStrings["Database"].ConnectionString));
  </code></pre>
  
  <p>In the previous version of structuremap  HttpContextScoped was available but with the latest version 3.0.0.0 it is no more available hence I have setup LifeCycle as HttpContextLifeCycle.</p>
  
  <p>Linq to Sql Datacontext objects are getting disposed and I get the below error:</p>
  
  <blockquote>
    <p>Cannot access a disposed object.\r\nObject name: 'DataContext accessed after Dispose'</p>
  </blockquote>
  
  <p>If I use <code>Singleton</code> or <code>ThreadLocalStorageLifecycle</code> scope for the <code>Datacontext</code> it's working fine. But I want to scope the <code>DataContext</code> objects to Per Http Request.</p>
  
  <p>How can I scope the <code>Datacontext</code> object to per Http Request?</p>
  
  <p>I referred the following article  but it is not working for <code>HttpContextLifeCycle</code>:</p>
  
  <p><a href="http://ignipro.blogspot.in/2012/09/structuremap-scopes-and-life-cycles.html" rel="nofollow">http://ignipro.blogspot.in/2012/09/structuremap-scopes-and-life-cycles.html</a></p>