The answer is almost always yes.
Not to say that you will always use the synchronization context, but given the nature of message handlers, filters, and formatters, you cannot predict whether they will require the use of a SynchronizationContext in order to access the HttpContextBase .
Even with filters where you pass something that gives you access to the HttpContext (let's say through the IActionFilter implementation ) that the HttpContext will ultimately look at the current CallContext in the stream to provide information from this instance. Since the current thread (when starting async) does not have this information when starting Task , these calls will not be made.
However, if you need general, unlimited access to the HttpContextBase associated with the request, then you absolutely need to go around the SynchronizationContext in order to access it.
However, if possible, you should copy the data from the HttpContextBase that you need and transfer it; if you write something very generalized, then it will be impossible.
casperOne
source share