Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 11, 2013 10:37 PM by callmedev
Jan 09, 2013 06:16 PM|LINK
In my test application I want to catch the deserialization exception if the request body contents not either valid XML or Json. Currently when I pass invalid XML/Json in the body I am not seeing any exception, instead getting HttpStatus 200. But while debugging
I am seeing the object is null as the deserializtion did not work properly. I have a custom global exception filter, but it seems like it is not intercepting that exception.
Jan 11, 2013 12:18 PM|LINK
Can you post your code.
Jan 11, 2013 10:37 PM|LINK
I found the answer myself. Custom global exception handler only works if the exception is thrown from any of the controllers in the Web API. But if the exception is thrown before the controller is invoked in the web api processing pipeline, it will not get
captured. The work around I found is that in my custom DelegatingHandler(that I am using for logging), I am manually validating XML or Json format based on content-type header.