Model validation in Web API - Exception is thrown with out a throw statement?
问题 I have seen the model validation from here (Under section: Handling Validation Errors ). The code-snippet is as below in Web API public class ValidateModel : ActionFilterAttribute { public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext) { if (actionContext.ModelState.IsValid == false) { actionContext.Response = actionContext.Request.CreateErrorResponse( HttpStatusCode.BadRequest, actionContext.ModelState); } base.OnActionExecuting(actionContext); }