Api method is looks like below
[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;
}
Upgrade my dotnet core from 2.0 to 2.1 thie become not working, can anyone help about this. What going wrong
The below code should work
Update [FromForm] attribute, and don't put parameter into Headers, and put name of key is file and brandId.
I tested, It is Ok
Make sure the form is the correct enctype
I also had to change how the Model bind from the generated
to
Change your method argument to take below model and add [FromForm], it should work.
In your form use
enctype="multipart/form-data"
I have found a workaround to make it work:
I was also surprised by this behavior. If someone can explain why it fixes the issue, it would help me.