小编Dus*_*vic的帖子

从 .NET Core 2.2 迁移到 3.0-preview-9 后,模型绑定停止工作

我有一个 Angular 前端应用程序和一个 ASP.NET Core 后端应用程序。一切都很好,直到我决定从 ASP.NET Core 2.2 迁移到 3.0-preview-9。

例如,我有一个 DTO 类:

public class DutyRateDto
{
    public string Code { get; set; }
    public string Name { get; set; }
    public decimal Rate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

以及一个示例 JSON 请求:

{
    "name":"F",
    "code":"F",
    "rate":"123"
}
Run Code Online (Sandbox Code Playgroud)

在迁移之前,这是一个有效的请求,因为它123被解析为小数。但是现在,在迁移后,我收到此正文的 HTTP 400 错误:

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "|3293cead-4a35656a3ae5e95b.",
    "errors": {
        "$.rate": [
            "The JSON value could not be converted to …
Run Code Online (Sandbox Code Playgroud)

c# .net-core asp.net-core angular asp.net-core-3.0

6
推荐指数
1
解决办法
683
查看次数

标签 统计

.net-core ×1

angular ×1

asp.net-core ×1

asp.net-core-3.0 ×1

c# ×1