我有这个简单的模型,其中PascalCase中的属性是C#中的默认约定:
public class ItemUpdateModel
{
[Required]
[Display(Name = "descriptionText")]
[MaxLength(200)]
public string DescriptionText { get; set; }
[Required]
[Display(Name = "priceUpdate")]
public double? PriceUpdate { get; set; }
}
当我从ModelState返回结果时,我得到PascalCase中显示的属性/字段,如下所示:
{
"message": "Validation Failed",
"errors": [
{
"field": "PriceUpdate",
"message": "The priceUpdate field is required."
},
{
"field": "DescriptionText",
"message": "The descriptionText field is required."
}
]
}
我在startup.cs中添加了CamelCasePropertyNamesContractResolver()而没有结果。