Unified code in net9 is normal, but from .net9 to .net10, aspnet core model bind has a json error (original) (raw)
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
when Request.ReadStringAsync() , model bind has a error:
public static async ValueTask ReadStringAsync(this HttpRequest request)
{
if (request.ContentLength == null || request.ContentLength < 1) return string.Empty;
request.EnableBuffering();
request.Body.Position = 0;
var body = await request.BodyReader.ReadStringAsync();
request.Body.Position = 0;
return body;
}
"The JSON value could not be converted to AppOS.IAM.Application.Authentication.LoginByPassword. Path: $ | LineNumber: 0 | BytePositionInLine: 12.",
"The command field is required."
[ApiController]
[ApiVersion(1.0)]
[Route("v{version:apiVersion}/[controller]")]
public sealed class AccountsController
{
public async Task<AuthenticatedResult?> LoginByPasswordAsync([FromBody] LoginByPassword command, CancellationToken token = default);
}
public sealed class LoginByPassword
{
public string Account { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.net10
Anything else?
No response