ASP.NET Core – How to receive a file in a web API request

When the client posts a file in a multipart/form-data request, it’s loaded into an IFormFile object. This contains file information (such as the file name) and exposes the file content as a stream. This allows you to save the file content or process it however you want to. You can access the IFormFile object through … Read more

ASP.NET Core – Get posted form data in an API Controller

To get posted form data in an API Controller (using the [ApiController] attribute) in ASP.NET Core, use parameters with the [FromForm] attribute. Now send a request with form data to this endpoint to see it work. The request would look like this: The form data is a string of key-value pairs (ex: location=United+States). The framework … Read more