Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
public class Test
{
public int? ID { get; set; }
public string Code { get; set; }
[Required]
public string Name { get; set; }
public DateOnly? Birthday { get; set; }
public DateTime? AddTime { get; set; }
public IFormFile File { get; set; }
public IFormFile[] Files { get; set; }
public static ValueTask BindAsync(HttpContext context) { return ValueTask.FromResult(new Test()); }
}
public static IResult SubmitForm([FromForm] Test test, [NotNull] string flag)
{
//todo
}
1、An empty string cannot be bind to a value type property.
Microsoft.AspNetCore.Http.BadHttpRequestException: The value '' is not valid for 'Birthday'.
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Log.FormDataMappingFailed(HttpContext httpContext, String parameterTypeName, String parameterName, FormDataMappingException exception, Boolean shouldThrow)
at lambda_method78(Closure, Object, HttpContext, Object)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass103_2.<b__2>d.MoveNext()`
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
net9.0
Anything else?
No response
Activity