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;
}
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; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.