Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Issue: Consider enforcing data annotation attributes on action parameters [24]

$
0
0
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.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>