0

理由はわかりません。単純明快なのですが、不思議なことに、うまくいきません。私は常にNULLコントローラーのモデルとして受け取ります。コードは次のとおりです。

モデル

public class EnrolleePlaces
{
    [HiddenInput(DisplayValue=false)]
    public int id { get; set; }

    public string SpecialtyCode { get; set; }

    public string Specialty { get; set; }

    public int Places { get; set; }
}

コントローラ

public ViewResult EditPlaces(int id)
{
      return View(repo.EnrolleePlaces.FirstOrDefault(p => p.id == id));
}

[HttpPost]
public ActionResult NewPlaces(EnrolleePlaces places) // 'places' is ALWAYS null
{
       if (ModelState.IsValid)
       {
           repo.SaveEnrolleePlaces(places);
           return RedirectToAction("Settings");
       }
       return View("EditPlaces", places);
}

public ViewResult CreatePlaces()
{
      return View("EditPlaces", new EnrolleePlaces());
}

そして、ビュー

@model Domain.Entities.EnrolleePlaces

@{
    Layout = null;
}

Edit: @Model.Specialty

@using (Ajax.BeginForm("NewPlaces", "Enrollee", new { area = "Admin" },
new AjaxOptions() { UpdateTargetId = "AdminContent" } ,
new { enctype = "multipart/form-data" }))
{
    @Html.EditorForModel()
    // here is input type="submit"
}

プロジェクトには同じパターンで作成されたコントローラーが 15 個以上ありますが、この 1 つだけがおかしい

4

1 に答える 1