I get the following default standard error message with a bad request response whenever the query parameter page is not valid.
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-ase4556503808167887c13a5978d0b-88001bf112e7555d-00","errors":{"page":["The value ''
is invalid."]}}
Similarly when the request body is invalid Json , the framework responds with similar error message as well.
I am catching all the exceptions that are thrown application wide using an ExceptionFilter.
How would I capture these particular bad request responses and format them and respond back with custom error format? What kind of Filter, Middleware or ModelBinder should I be using ?
SuppressModelStateInvalidFilterto true as described in this Q&A and by Microsoft themselves here