I've been working with quite some Web API projects now and find myself bumping into the same problem every time and that's when I do a POST or GET the value / model etc is null or I get a 404.
There is a checklist like: - did I use the correct content-type? - has routing been set up correctly - is the signature of the model that I'm posting really the same as the model that the endpoint accepts?
It would be nice if there is a trace one could follow where it fails. Now it just looks like a black box, you put something in and it works or not, if it doesn't: see checklists or SO.
Is there something that you can setup in Web API so you can debug the model binding process?
I would implement action filter.
One of the methods that can be overridden there is :
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
In this action you can check the response status and if it is an error to perform all your checks
This article could be a good starting point
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