IFormFile always return null in asp.net core 2.1

前端 未结 11 1836
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 11:52

Api method is looks like below

    [HttpPost]
    public async Task> MediaBrand(IFormFile file, int brandId)
         


        
11条回答
  •  时光说笑
    2021-01-11 12:27

    Change your method argument to take below model and add [FromForm], it should work.

    public class FileUploadViewModel
    {
        public IFormFile File { get; set; }
        public int BrandId { get; set; }
    }
    
    public async Task> MediaBrand([FromForm] FileUploadViewModel viewModel)
    

提交回复
热议问题