Is there an existing issue for this?
Describe the bug
Model binding fails when a [FormQuery] parameter has the same name as a property of the model.
public class TestParameter
{
public string Parameter { get; set; };
}
[ApiController]
public class TestController()
{
[HttpGet("test")]
public TestParameter Test([FromQuery] TestParameter parameter)
{
return parameter;
}
}
HTTP GET /test?Parameter=test
Looks like it's related to here
|
else if (modelBindingContext.ValueProvider.ContainsPrefix(parameter.Name)) |
When the name of the model is the same as the model attribute name, the binding intention cannot be easily determined by the prefix
Expected Behavior
HTTP GET /test?Parameter=test
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.100-preview.7.24407.12
Anything else?
No response
Is there an existing issue for this?
Describe the bug
Model binding fails when a [FormQuery] parameter has the same name as a property of the model.
HTTP GET /test?Parameter=test
{ "parameter": null }Looks like it's related to here
aspnetcore/src/Mvc/Mvc.Core/src/ModelBinding/ParameterBinder.cs
Line 121 in c4601ad
When the name of the model is the same as the model attribute name, the binding intention cannot be easily determined by the prefix
Expected Behavior
HTTP GET /test?Parameter=test
{ "parameter": "test" }Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.100-preview.7.24407.12
Anything else?
No response