请参阅以下代码:
@model NHibernate.AspNet.Identity.IdentityRole
@{
ViewBag.Title = "Edit";
Layout = "~/Areas/Administration/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)
<div>
Role name
</div>
<p>
@Html.TextBoxFor(model => model.Name)
</p>
<input type="submit" value="Save" />
}
以及以下代码:
[HttpPost]
public ActionResult Edit(IdentityRole role)
{
Service.Update(role);
TempData["Comment"] = "The record was updated";
return RedirectToAction("Index");
}
Role.Id在控制器中始终为null。 Role.Description包含正确的值。
角色不会更新,因为Role.Id为null。有什么问题?