Missing required value for constructor parameter
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### 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
```
public record PostParameter([Required][EmailAddress] string Email, [Required][MinLength(8)] string Password, string? RememberMe = "unchecked");
internal static async Task> Post(HttpContext httpContext, [FromForm] PostParameter parameter)
```
PostParameter has optional parameter but that optional parameter is not respected
```
BadHttpRequestException: Missing required value for constructor parameter 'RememberMe'.
Microsoft.AspNetCore.Http.RequestDelegateFactory+Log.FormDataMappingFailed(HttpContext httpContext, string parameterTypeName, string parameterName, FormDataMappingException exception, bool shouldThrow)
```
### 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_
Contributor guide
Assessment
This issue has not been assessed yet.