title: Error:The connection was not closed. The connection's current state is connecting
body: <p>I have MVC-Api (Entity framework) where i'm recently started to get this kind of errors. (Not all the time)</p>
  
  <pre><code>System.Data.EntityException: The underlying provider failed on Open. ---&gt; System.InvalidOperationException: The connection was not closed. The connection's current state is connecting.
  
  System.Data.EntityException: The underlying provider failed on Open. ---&gt; System.InvalidOperationException: The connection was not closed. The connection's current state is open.
  
  //web.config
  &lt;add name="Entities" providerName="System.Data.EntityClient"  connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=localhost ;Initial Catalog=MyDB;Integrated Security=SSPI;Application Name=Api;MultipleActiveResultSets=True;&amp;quot;" /&gt;
  //Run on IIS as local system.
  </code></pre>
  
  <p>From Global.asax the connection is registered LifestylePerWebRequest mode.</p>
  
  <pre><code>//registered
  public static void RegDbContext()
  {
    Container.Register(Component.For&lt;Entities&gt;().LifestylePerWebRequest());
  }
  //Resolved
  public static T Resolve&lt;T&gt;()
  {
    return Container.Resolve&lt;T&gt;();
  }
  
  
  //In the code.
  var Entities = IoCHelper.Resolve&lt;Entities&gt;();
  //code
  var metaData = (from user in Entities.Users where user.Id == id)
  </code></pre>
  
  <p>Anybody that can give me some help? (Ps cant reproduce it localhost only on production enviorment)</p>
  
  <p>Update: it always happends in  ActionFilterAttribute. </p>
  
  <p>cache</p>
  
  <p>Thanks!</p>