This question already asks what I'm asking, but I want some clarification on the answer.
The answer states that WebGet
and WebInvoke
are similar, and that the primary difference is the Method
parameter.
But if the Method
parameter is set to "GET"
, is it actually functionally equivalent, or are there other differences?
They are simply marker attributes and end up being 100% functionally equivalent. The only thing that interprets these attributes is the
WebHttpBehavior::GetWebMethod
method and its functionality is simply:It is not.
I just spent few hours trying to replace WCF DataContractJsonSerializer with Newtonsoft JsonSerializer using MessageFormatter based on this and this samples
found out (the hard way) there IS difference in using
WebGet
andWebInvoke(Method="GET")
.With
WebInvoke
the request goes through different pipeline in WCF stack, trying to deserialize the expected message (methodIDispatchMessageFormatter.DeserializeRequest()
gets invoked) which is not the case withWebGet
.The lesson learned: use
WebGet
forGET
operation