I\'m using ASP.NET Core 2.0, and I have a request object annotated like this:
public class MyRequest
{
[Required]
public Guid Id { get; set; }
[
When you use [FromBody]
as binding source, the Model properties will get default values and [BindRequired]
will be ignored.
There is a related issue on "Problems with Parameter Validation".
In this case is better to use [JsonRequired]
instead of [BindRequired]
to enforce binding properties.
Note that [JsonRequired]
affects serialization and deserialization both.