I have recently upgraded from .NET 6 to .NET 8 where one of the existing API which accepts IFormFile and string data got impacted like the string data is coming as empty. As far as I know in .NET 8 the [FromForm] attribute is not needed so I removed that from the Angular UI and passing it as formdata. Not sure why still the data is coming as empty but file is passed. Can anyone help how to resolve this?
My API sample
From UI I will be passing as form
public async Task<ActionResult> upload(IFormFIle file, string data)
{
// ....
}
upload(file: File, data: string): Observable<any> {
const formData: FormData = new FormData();
formData.append('file', file, file.name);
formData.append('data', data);
return this.http.post(this.apiUrl, formData);
}