<form asp-controller="InputExamples" asp-action="StoreModel" method="post" class="form-horizontal" role="form">
<store-model asp-for="Value" class="json-data" />
<div class="form-group">
<div class="col-md-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
public class Person
{
public string Name { get; set; }
public string Surname { get; set; }
}
public class StoreModelExample
{
public Person Value { get; set; }
}
public IActionResult StoreModel()
{
return View(new StoreModelExample {
Value= new Person
{
Name = "Francesco",
Surname = "Abbruzzese"
}
});
}
[HttpPost]
public IActionResult StoreModel(StoreModelExample vm)
{
return View(vm);
}