What I have:
- A simple Web API - POST api/examples
- Postman to send the request.
When I make the request with the content type set as application/json everything works just fine. But when I change to anything else I get the following response:
{
"": [
"The input was not valid."
]
}
From Kestrel logs I get:
the application completed without reading the entire request body.
This is how the web api is handling invalid requests. What I want to find out is how can I capture and handle this kind of exception and change the default message.
I do have a error handling middleware, but in this scenario the request is invalid, so it's never called.
How can I change this default behavior?