Take the 2-minute tour ×

How can I customize the error message in HTTP response? Instead of below error I need to show custom error message in HTTP Response.

a:Deserialization FailedThe formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://Test/Common:SearchCriteria. The InnerException message was 'There was an error deserializing the object of type System.String. The byte 0x1D is not valid at this location. Line 1, position 307.'. Please see InnerException for more details.

share|improve this question
add comment

1 Answer

You'll need to implement a custom unhandled error handler. This excellent blog post covers how the error handler is implemented and your service configured to use it. You'll need to check for the unhandled exception for the deserialization specific type and create the custom error message to replace it.

share|improve this answer
add comment

Your Answer


