Hi all,
When upgrading to 1.1 my modelbinding from a form stopped working
public class test {
public int id {get;set;}
public string name {get;set;}
}
[HttpGet]
public async Task<IActionResult> doIt()
{
List<test> model = new List<test>();
test atest = new test();
atest.id = 1;
atest.name="First";
model.Add(atest);
atest = new test();
atest.id=2;
atest.name="Second";
model.Add(atest);
return View(model)
}
[HttpPost]
public async Task<IActionResult> doIt(List<test> model)
{
if(ModelState.IsValid)
{
//model.Count() is always Zero after upgrade to 1.1 :-)
}
}
//doIt.cshtml
@model List<test>
<form asp-action="doIt" method="post">
@foreach(test item in Model)
{
<label asp-for="@Model.First().id"></label>
<input type="hidden" asp-for="@item.id" value="@item.id" />
<label asp-for="@Model.First().name"></label>
<input type="hidden" asp-for="@item.name" value="@item.name" />
<button id="btnConfirm" type="submit" class="btn btn-info">Go On</button>
</form>}