This is a two part question:
Can someone provide a list of the ASP.NET/.NET properties that are typically thread local that flow with ExecutionContext?
HttpContext.Current? Thread.CurrentContext? Thread.CurrentPrincipal? Thread.CurrentCulture?
What properties can I count on surviving/persisting async/await?
What else?
Is there any way to add application specific Context information that will flow automatically with ExecutionContext? Something like
var ec = ExecutionContext.Capture();
ec.CustomContext["MyCustomContext"] = ACustomContext;
The best resource for this is ExecutionContext vs. SynchronizationContext by Stephen Toub. There is no list of properties like what you're looking for.
ASP.NET actually uses SynchronizationContext
to flow HttpContext.Current
, and treats Thread.CurrentPrincipal
rather oddly.
You can add your own context using LogicalSetData
/LogicalGetData
. However, you should only store immutable data. I document this on my blog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With