1 .net c# asp.net-mvc .net-core asp.net-core
当我在传递查询字符串时向 API 端点发送请求时,我遇到参数未绑定的问题,如果我展平提交,则参数会绑定,但这不是我想要的解决方案。我无法提供在第三方控件处理请求时发送请求的客户端代码。
我提供了随请求发送的查询字符串的示例,可以在开发人员工具中看到该示例,但是 Person 和 Property 返回为 null。有谁有任何建议,特别是我可以做的服务器端更改来绑定这个复杂的对象?谢谢。
public class Submission {
public Person Person {get; set; }
public Property Property { get; set; }
}
public class Person {
public int Age { get; set; }
}
public class Property {
public string Address { get; set; }
}
Query string parameters
'Person[Age]': 18
'Property[Address]': test
[HttpGet("action")]
public async Task<IActionResult> Submit([FromQuery] Submission model)
{
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,您要调用的 URL 是:
https://localhost:.../.../action?Person.Age=18&Property.Address=test
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4523 次 |
| 最近记录: |