I have created WebAPI using.NetCore 6.0. The API will receive a csv file and return the results as a csv file.
[HttpPost]
[Route("Search")]
public async Task<IActionResult> Search(IFormFile file)
{
StringBuilder sb = await GetList(int id);
return File(Encoding.ASCII.GetBytes(sb.ToString()), "text/csv", fileName);
}
But I would like to return a status code along with result data. Thank you.
Use of Ok() method from ControllerBase class, which your controller should extend.
return Ok(File(Encoding.ASCII.GetBytes(sb.ToString()), "text/csv", fileName));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.