The missing key reference is this blog post. Specifically, you need to either set UseTaskFriendlySynchronizationContext
or set targetFramework
to 4.5
. Creating a new project sets targetFramework
to 4.5
, so you do get the correct behavior (UseTaskFriendlySynchronizationContext
is implicitly set to true
).
To answer your specific questions:
- The setting affects ASP.NET request handling for all kinds of requests, not just WebForms.
- Most
async
tutorials assume a GUI application scenario. - I'm not sure; I think this would be better as a separate question. My gut feeling is that you can't depend on
Thread.CurrentPrincipal
after you leave the ASP.NET context.