编辑视图中需要隐式传地一些属性,可以通过 hidden input 传递它们:
<form enctype="multipart/form-data" asp-controller="Home" asp-action="Edit" method="post" class="mt-3">
<input hidden asp-for="Id" />
<input hidden asp-for="ExistingPhotoPath" />
<div class="form-group row">
<label asp-for="Name" class="col-sm-2 col-form-label"></label>
<div class="col-sm-10">
<input asp-for="Name" class="form-control" placeholder="请输入名字" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
...
</form>