에서 null을 반환 내 HTTP 게시물입니다 : 내 GET에서 그것을 채우기왜이 내 모델 내보기 모델
public class Attribute
{
public string Key { get; set; }
public string Value{ get; set; }
}
만들
public ActionResult Create()
{
var Attributes = new[]
{
new Attribute {Key = "Name" Value = "" },
new Attribute {Key = "Age" Value = "" },
};
return View(Attributes);
}
내보기 다음과 같습니다
@model IEnumerable<Customers.ViewModels.Attribute>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
@foreach (var item in Model)
{
<div class="editor-label">
@Html.Label(item.Key)
</div>
<div class="editor-field">
@Html.EditorFor(m => item.Value)
@Html.ValidationMessageFor(m => item.Value)
</div>
}
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
내 게시물 작성은 다음과 같습니다.
[HttpPost]
public ActionResult Create(IEnumerable<Attribute> attributes)
{
}
그러나 내 IEnumerable<Attribute> attributes
은 null입니다. 어떤 제안?
귀하의 GET이 반환됩니다. 속성이 아닙니다. –
예, 그렇습니다. – Pittfall
입니다. IEnumerable <>을 (를) 예상하고 있습니다. 내 잘못입니다. –