Receive file and other form data together in ASP.NET Core Web API (boundary based request parsing)
.net-core, asp.net, asp.net-core, c#
Solution
I had the similar issue and I solved the problem by using `[FromForm]` attribute and `FileUploadModelView` in the function as follow:
[HttpPost]
[Route("upload")]
public async Task<IActionResult> Upload([FromForm] FileUploadViewModel model, [FromForm] string member_code)
{
var file = model.File;
// ...
}
Problem
How would you form your parameters for the action method which is supposed to receive one `file` and one `text` value from the request? I tried this ``` public string Post([FromBody]string name, [FromBody]IFormFile imageFile) ``` And tried hitting it from Postman but it gives me `500 Internal Server Error`. I also can't debug it because it never hits the first statement inside the action method where I've put my breakpoint. Any idea how can we parse boundary based requests and extract file(s) and other textual field(s)? I am new to ASP.NET Core.