-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Consider adding UnprocessableEntityResult and ControllerBase.UnprocessableEntity #6795
Comments
Thanks for the suggestion, we'll review the request in our next bug triage meeting. |
Seems reasonable. We need to add it to both MVC's See also #6172 |
I can do the work if you want 😊 |
go for it! 👍 Should include |
Hmm... I can't seem to find Also, there's no existing |
@DamianEdwards / @rynowak - thoughts on adding various other missing result factory methods? Were we trying to avoid more API-ish things appearing in Razor Pages or anything like that? Or do we want parity? |
Yeah, let's leave it out for now. No one has asked for it |
Should the public virtual BadRequestObjectResult BadRequest(ModelStateDictionary modelState); Perhaps the method should be marked with the Obsolete attribute? |
Note that the |
It's not obsolete, it's just that there's no consensus on using 400 for validation errors. Some people use 400 for all client errors, like syntax and validation, while some prefer 400 for syntax error and 422 for semantic validation errors. MVC will still default to 400. |
422 Unprocessable Entity
is commonly used for semantic validation errors in APIs, as opposed to400 Bad Request
for syntactical errors:It would be nice if MVC included an
UnprocessableEntityResult
and an accompanyingControllerBase.UnprocessableEntity
method.They'd basically mirror what
BadRequestResult
andControllerBase.BadRequest
does, only with a different status code.This has been requested before by @ashmind, but was never followed up.
The text was updated successfully, but these errors were encountered: