export data.csv for GET method with query parameters?
This works great. I want to pass the query parameters to this get method and export data.csv. Is there a way to do it?
You will probably have to manually set the response type and stuff. I think it only works right now because the browser sees the .CSV extension
You would have to implement a normal GET request with parameters and also set the response to the correct media type. Or you could return all responses as a CSV.
after long search, i decided to use byte streaming instead which works as what i expected. Right now, i don't require to import csv file.
[HttpGet]
public async Task<IActionResult> Download([FromQuery] LogQueryResource queryResource)
{
\\ i apply filter, get the data and append to line.
byte[] buffer = Encoding.ASCII.GetBytes($"{string.Join(",", ColumnHeaders)}\r\n{data.ToString()}");
return File(buffer, "text/csv", "data.csv");
}