I have a RESTful WCF service that have a service method say BeginX()
Inside BeginX, I call my static Validate function in a static helper class. Inside the static Validate method, can I call WebOperationContext.Current.OutgoingResponse.StatusCode = blah?
What is the expected behavior when current context is called from inside static methods in my service?
(I tried prototyping it, but I can't seem to get a WebOperationContext when I try to get it from an in-proc WCF service that runs in my console app)
WebOperationContext.Current
is a static property, and is available to any method, static or otherwise, as long as the method is running on that thread.This will result in the following outputs:
The first call to
CheckWebOperationContext
is on the same thread, so the context is available to it. The second call is on a different thread, so the context is not available.