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); } }
public HttpResponseMessage PostEmployee(Employee emp) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
No comments:
Post a Comment