Monday, 31 December 2018

How to handle Model Validation using HttpError ?

For model validation, pass the model state to CreateErrorResponse as follows:

public HttpResponseMessage PostEmployee(Employee emp) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }

No comments:

Post a Comment