I am pretty sure I did it before but I can't remember how. Do I have to use some annotation? As noted in the title I am using asp.net core.
I have a form element,
//my attempt was like this.
<input name="Address.Number" />
My action is,
public IActionResult Register(Client client)
{
.....
}
The class Client has a nested complex object.
public class Client
{
public Address address = new Address()
}
public class Address
{
public int Number;
}
答案 0 :(得分:0)
You need to use properties instead of fields:
public class Client
{
public Address Address { get; set; } = new Address()
}
public class Address
{
public int Number { get; set; }
}