【发布时间】:2017-06-06 11:22:54
【问题描述】:
从 .net 4.6 迁移到 .net core 1.1 后,Model Binding 的接受程度大不相同,如下:
-
对于 .net 4.6,模型绑定通过接受请求参数(查询字符串)来工作,如下所示
边界[TopLeft][Lat]:10.808969811804062
边界[TopLeft][Lon]:106.63826676953124
边界[BottomRight][Lat]:10.785699937603939
边界[BottomRight][Lon]:106.72066423046874
中心[纬度]:10.7973351
中心[lon]:106.6794655
限制:1000 -
对于.net core 1.1,模型绑定通过接受请求参数(查询字符串)来工作,如下所示
Boundary.TopLeft.Lat:10.808969811804062
Boundary.TopLeft.Lon:106.63826676953124
Boundary.BottomRight.Lat:10.785699937603939
Boundary.BottomRight.Lon:106.72066423046874
Center.lat:10.7973351
Center.lon:106.6794655
限制:1000
因此,来自客户端的所有查询都失败了(模型绑定显示空对象)。 .net 核心是否有任何配置可以接受 Boundary[TopLeft][Lat] 而不是 Boundary.TopLeft.Lat?
【问题讨论】:
-
更准确地说,我使用jQuery执行ajax请求(GET/POST)来查询边界用户,jQuery将请求的数据解析为Boundary[TopLeft][Lat],完全没有问题使用 .net 4.6 API。但是,.net core 1.1 需要 Boundary.TopLeft.Lat 格式,否则将无法读取。
标签: asp.net-core model-binding