Compound View Model object causing remote validation failure

后端 未结 2 1622
庸人自扰
庸人自扰 2021-01-05 06:14

I have used a pattern of compound view models for a few of the forms in this project. It works very well.

In this case I have a VendorAddress view model. I use Add

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 06:35

    Try specifying a prefix to help the model binder correctly bind the Address.PostalCode and Address.State request values to their corresponding action parameters:

    public ActionResult CheckState(
        [Bind(Prefix = "Address.State")]string State, 
        [Bind(Prefix = "Address.PostalCode")]string PostalCode
    )
    {
        ...
    }
    

提交回复
热议问题