【发布时间】:2020-05-18 17:48:51
【问题描述】:
在使用 Razor 页面的 ASP.NET Core 3.1 项目中,我有以下页面模型:
[BindProperty]
public AddUserPageModel Input { get; set; }
public class AddUserPageModel
{
public string UserName { get; set; }
public string Password { get; set; }
public List<IFormFile> ImageUploads { get; set; }
}
从这个 Razor 页面视图中,我插入一个局部视图并传递作为单个属性的模型:
<partial name="Partials/_AddPhotos" model="@Model.Input.ImageUploads" />
在局部视图中:
@model List<Microsoft.AspNetCore.Http.IFormFile>
<input asp-for="@Model" type="file" multiple>
这会导致以下错误:
System.ArgumentException: The name of an HTML field cannot be null or empty.
所以看来问题在于部分观点,asp-for="@Model" 需要 .PropertyName 但我不确定如何实现这一点?
【问题讨论】:
标签: c# asp.net asp.net-core