我的行动方法:
[HttpPost, ActionName("Delete")]
[RequiredPermissions(RequiredPermissionName, Operation.Delete)]
public ActionResult DeleteConfirmed(User userWhoGone)
{
_db.Users.Remove(userWhoGone);
_db.SaveChanges();
this.TempData["msg"] = "Deleted User Id " + userWhoGone.Id;
return RedirectToAction("Index");
}
删除.cshtml
@model NewsMonitoringWeb.Database.Models.User
@{
ViewBag.Title = "User Delete";
<h2>User Delete</h2>
<h3>Are you sure you want to delete this user?</h3>
@Html.Partial("_PartialUser")
@using (Html.BeginForm()) {
<p>
<input type="submit" value="Delete" /> |
@Html.ActionLink("Back to List", "Index")
</p>
}
_PartialUser.cshtml
@model NewsMonitoringWeb.Database.Models.User
<fieldset>
<legend>User</legend>
<div class="display-label">User Role</div>
<div class="display-field">
@Html.DisplayFor(model => model.UserRole.Name)
</div>
<div class="display-label">FirstName</div>
<div class="display-field">
@Html.DisplayFor(model => model.FirstName)
</div>
<div class="display-label">LastName</div>
<div class="display-field">
@Html.DisplayFor(model => model.LastName)
</div>
<div class="display-label">Email</div>
<div class="display-field">
@Html.DisplayFor(model => model.Email)
</div>
<div class="display-label">Is Contributor</div>
<div class="display-field">
@Html.DisplayFor(model => model.IsContributor)
</div>
</fieldset>
我使用 chrome 检查发布的数据,我发现这种方法没有向服务器发布任何内容。
有什么建议吗?