-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Missing required value for constructor parameter #56234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Workaround, dont use record
|
It should work without [FromForm] too |
The drama supporting "form" in minimal api |
@andrew-vdb Thanks for opening this issue! I hope I can clarify some of the confusion here. There are currently two different form-binding strategies in minimal APIs:
The reason the workaround that you describe here works is minimal APIs treats all parameters with a default value as optional. That same convention doesn't apply to the complex form-binding strategy shared with Blazor. It looks like the reason this bug is happening is because the complex form-binding support always sets constructor parameters as required: aspnetcore/src/Components/Endpoints/src/FormMapping/Metadata/FormDataParameterMetadata.cs Line 13 in 0da8ea7
I'll see if I can update the complex form-binding implementation here so it handles constructor parameters in records with default values correctly (and nullable constructor parameters). |
@captainsafia got bitten with different issue, basically with POCO object with minimal api, the default value in the property also not applied, this was simply work with controller so the question is, is the workaround above, not using poco object is the way to go for minimal api? is this real recommendation? if true then can we have it somewhere it documentation? |
Is there an existing issue for this?
Describe the bug
How difficult can this be
Checkbox in html form when its not true, simply not to submit the value in the property
PostParameter has optional parameter but that optional parameter is not respected
Expected Behavior
should simply accept (no exception) when client not sending "RememberMe" in the payload
Steps To Reproduce
No response
Exceptions (if any)
FormDataMappingException
.NET Version
8
Anything else?
No response
The text was updated successfully, but these errors were encountered: