Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

ValidateModelStateAttribute

Trevor Pilley edited this page May 20, 2014 · 1 revision

The ValidateModelStateAttribute validates the model state in a request and returns a HTTP 400 Bad Request if it is invalid, it saves having to wrap all your methods with if (ModelState.IsValid()).

There are times when you may want to opt out individual actions:

[ValidateModelState(SkipValidation = true)] // will only affect individual methods
public HttpResponseMessage Edit(int id, Model model) { ... }
Clone this wiki locally