Error assigning null to a nullable int - “The value 'null' is not valid for property”

后端 未结 6 775
耶瑟儿~
耶瑟儿~ 2020-12-28 16:50

I have this property in my view model:

[DisplayName(\"Region\")]
public int? RegionId { get; set; }

I pass my view model to my controller,

6条回答
  •  长情又很酷
    2020-12-28 17:44

    See here: ModelState validation fails for nullable types

    The string "null" may be being passed. In my scenario I updated to an empty string "" and resolved this error.

提交回复
热议问题