I'm uploading CSV file from client to .NET CORE Web Api app.
I'm using CsvHelper .net library.
I receive file successfully and I would like to parse it to my custom classes so I could loop throught the rows from csv.
But everytime I get Empty result like there are no rows.
I'm not sure what is wrong with my approach:
[HttpPost("import")]
public async Task<ActionResult> ImportData([FromForm] IFormFile file)
{
using var memoryStream = new MemoryStream(new byte[file.Length]);
await file.CopyToAsync(memoryStream);
memoryStream.Position = 0;
using (var reader = new StreamReader(memoryStream))
using (var csvReader = new CsvReader(reader, System.Globalization.CultureInfo.InvariantCulture))
{
csvReader.Read();
var records = csvReader.GetRecords<SiteDto>();
}
return Ok("ok");
}
This is how my CSV looks a like:
My Site Dto:
public class SiteDto
{
public long Id { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public string CompanyName { get; set; }
public string Location { get; set; }
}
And when I expand my result I saw something like warning about some headers?


using varworks - it gets disposed when it goes out of scope.