title: asp.net mvc async controller vs session state
body: <p>I think this is a recurring question but I couldn't find an specific answer to my doubt.</p>
  
  <p>I have a Asp.net MVC3 application, we are going to switch to AsyncController to improve the app and I think all the setup is done right. However, this app will run in load balancer with one central session state server. Asp.net State Service.</p>
  
  <p>The request to need to read from session, so with hundreds parallel requests from many users will requests end up queuing up due to session object serialization back and forth to the state server? Or worst will I end up with session object NULL if my Task.StartNew() thread takes a while to complete? And that multiplied by many users ...</p>
  
  <p>I guess forget writing to session on these requests right? Would it give error or just ignore the written value?</p>
  
  <p>Let's suppose thread pool size is not in the equation, I'd like to understand how session (wait) behaves in this scenario.</p>
  
  <p><strong>EDIT</strong>
  Can you explain why this works and is it granted in all stress scenarios?</p>
  
  <pre><code>var current = System.Web.HttpContext.Current;
  
              AsyncManager.OutstandingOperations.Increment();
              Task.Factory.StartNew(() =&gt;
              {
                  System.Web.HttpContext.Current = current;
  </code></pre>
  
  <p>Thanks</p>