模型不为null,但子对象为null

时间:2017-04-12 01:27:35

标签: binding asp.net-mvc-5

在回发时,我的模型存在,但它的子对象Policy为空。

我做错了什么?

控制器

[HttpPost]
public ActionResult Wizard([Bind(Include = "Policy")] InformationModel model, Directions direction)
{
   return View(model);
}

模型

public class InformationModel
{
    public GHCOPPAType Policy;
}

查看

@model GHCOMvc.Models.InformationModel

@using (Html.BeginForm("Wizard", "Policy", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.HiddenFor(m => m.Policy.Id)

    <button class="btn btn-success" name="direction" value="Next">Next</button>
}

0 个答案:

没有答案