【发布时间】:2021-02-23 21:28:45
【问题描述】:
我在传递查询字符串时向我的 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)
{
}
【问题讨论】:
-
在查询字符串中尝试
Person.Age。
标签: c# .net asp.net-mvc asp.net-core .net-core