asp.net - How do I trap a SerializationException in Web API? -


i have asp.net web api web service throws serializationexception in circumstances. problem i'm unable trap , log exception server-side -- place shows in body of http response client.

i registered exceptionfilterattribute described in exception handling in asp.net web api , verified works when throw exception within controller. unfortunately serializationexception being thrown during response (after controller) , appears swallowed asp.net. tried hooking application_error() in global.asax.cs didn't show there either.

how can catch serializationexception exceptions during web api response?

if, instead of returning object, use apicontroller.createresponse() method , return httpresponsemessage can response.content.loadintobufferasync().wait() , force serialization happen whilst still in action , therefore can catch exception.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -