Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>As I understand it during Async operations the ASP.NET thread originally running the operation is returned to the thread pool and a different thread may be used to finish the request after the Async operation has completed.</p> </blockquote> <p>That is correct. But let's talk about <code>async</code> on ASP.NET for just a minute.</p> <p><code>async</code> requires .NET 4.5. Furthermore, ASP.NET 4.5 introduces a "quirks mode" on the server side, and you have to turn the <code>SynchronizationContext</code> quirk <em>off</em>. You can do this by either setting <code>httpRuntime.targetFramework</code> to <code>4.5</code> <em>or</em> using an <code>appSettings</code> with <code>aspnet:UseTaskFriendlySynchronizationContext</code> value of <code>true</code>.</p> <p>If your web.config does not have one of those entries, then the behavior of <code>async</code> is undefined. See <a href="http://blogs.msdn.com/b/webdev/archive/2012/11/19/all-about-httpruntime-targetframework.aspx" rel="noreferrer">this post</a> for more details. I recommend using the <code>targetFramework</code> setting and fixing any problems that come up.</p> <blockquote> <p>Does this affect the HttpContext.Current.Items collection? Is an item that was in the Items collection guaranteed to be there when the Request resumes?</p> </blockquote> <p>The <code>AspNetSynchronizationContext</code> preserves the current request context across <code>await</code> points. This includes <code>HttpContext.Current</code> (which includes <code>Items</code>, <code>User</code>, etc).</p> <p>Another possibility is <code>CallContext.Logical[Get|Set]Data</code>, which also flows across <code>await</code> points. This is useful if you don't want a code dependency on <code>HttpContext</code>, but has slightly more overhead.</p> <p>I gave a talk at ThatConference a couple weeks ago on <a href="http://blog.stephencleary.com/2013/08/slides-available-thatconference-2013.html" rel="noreferrer"><code>async</code> on the server side</a>; you may find the slides helpful, particularly the ones dealing with Context and Thread-Local State.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload