If an empty request is sent to the action below, the parameter "p" is null, and there are no model errors, since [Required] (and I assume other Data Annotation attributes) are not enforced for action parameters. It'd be nice to have that to have one single place for checking input errors (model state), instead of in this case having to make two checks (p != null and check model state).
public string Post([Required] Person p) {
...
}
Comments: The correct way to do that check is via an action filter, not decorating the every action. BTW, we do use C# syntax to inform the action selector as which parameter is option. But I think this bug is really asking to fail the action when model binding failed.
public string Post([Required] Person p) {
...
}
Comments: The correct way to do that check is via an action filter, not decorating the every action. BTW, we do use C# syntax to inform the action selector as which parameter is option. But I think this bug is really asking to fail the action when model binding failed.