我正在尝试使用 IFormFile 作为嵌套 ViewModel 中的属性。我在尝试在运行时将 ViewModel 绑定到控制器操作时遇到了问题。AJAX 请求停止并且永远不会到达操作。
这个概念性问题参考了我在 .NET Core ViewModel中的IFormFile 属性中导致停滞的 AJAX 请求的特定问题
public class ProductViewModel
{
public ProductDTO Product { get; set; }
public List<ProductImageViewModel> Images { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
public class ProductImageViewModel
{
public ProductImageDTO ProductImage { get; set; }
public IFormFile ImageFile { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
[HttpPost]
public IActionResult SaveProduct([FromForm]ProductViewModel model)
{
//save code
}
Run Code Online (Sandbox Code Playgroud)
我想知道 IFormFile 属性是否需要是您绑定到控制器操作的 ViewModel 的直接属性。
该IFormFile文档似乎并没有回答我的问题。
api方法如下图
[HttpPost]
public async Task<BaseListResponse<MediaStorageModel>> MediaBrand(IFormFile file, int brandId)
{
var files = new List<IFormFile>();
files.Add(file);
var response = await this.Upload(files, "brand", brandId);
return response;
}
Run Code Online (Sandbox Code Playgroud)
将我的dotnet核心从2.0升级到2.1不能正常工作,任何人都可以帮忙。出什么事了