12345678910111213141516171819 |
- using System.Net;
- using System.Net.Http;
- using System.Web.Http.Controllers;
- using System.Web.Http.Filters;
-
- namespace iiie.WebApiUtils.BusinessManager.Attributes
- {
- public class ValidateModelStateAttribute : ActionFilterAttribute
- {
- public override void OnActionExecuting(HttpActionContext actionContext)
- {
- if (!actionContext.ModelState.IsValid)
- {
- actionContext.Response = actionContext.Request.CreateErrorResponse(
- HttpStatusCode.BadRequest, actionContext.ModelState);
- }
- }
- }
- }
|