Service Method hits twice. On client side you get “Bad request ” HTTP request…

Why?

You send the correct parameters to your asynchronous post operation, you verify all the parameters are set. You debug the method giving “Bad request error” message and find , the debug point is being hit , but it is being hit twice ..

You check all the service method calls, but at every place, they are called only once.. So what’s the reason of service method being hit twice…

When writing contracts for your services, do check for these two important points.

1) KnownType Attribute  – Incase your result is a user defined class with collection of more user defined classes, include all the classes and their collections using this attribute. If any type is missed the service method cannot recognize the type and gets hit twice .

2) Every class being passed in service method should be decorated with DataContract. If not you might face above issue.