title: I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it
body: <p>I just discovered that every request in an ASP.Net web application gets a Session lock at the beginning of a request, and then releases it at the end of the request!</p>
  
  <p>In case the implications of this are lost on you, as it was for me at first, this basically means the following:</p>
  
  <ul>
  <li><p>Anytime an ASP.Net webpage is taking a long time to load (maybe due to a slow database call or whatever), and the user decides they want to navigate to a different page because they are tired of waiting, THEY CAN'T! The ASP.Net session lock forces the new page request to wait until the original request has finished its painfully slow load. Arrrgh.</p></li>
  <li><p>Anytime an UpdatePanel is loading slowly, and the user decides to navigate to a different page before the UpdatePanel has finished updating... THEY CAN'T! The ASP.net session lock forces the new page request to wait until the original request has finished its painfully slow load. Double Arrrgh!</p></li>
  </ul>
  
  <p>So what are the options?  So far I have come up with:</p>
  
  <ul>
  <li>Implement a Custom SessionStateDataStore, which ASP.Net supports.  I haven't found too many out there to copy, and it seems kind of high risk and easy to mess up.</li>
  <li>Keep track of all requests in progress, and if a request comes in from the same user, cancel the original request.  Seems kind of extreme, but it would work (I think).</li>
  <li>Don't use Session!  When I need some kind of state for the user, I could just use Cache instead, and key items on the authenticated username, or some such thing. Again seems kind of extreme.</li>
  </ul>
  
  <p>I really can't believe that the ASP.Net Microsoft team would have left such a huge performance bottleneck in the framework at version 4.0! Am I missing something obvious? How hard would it be to use a ThreadSafe collection for the Session?</p>