We utilised the CSVHelper to upload CSV file with date column and worked ok on dev machine till we published into Azure the following issue:
An unhandled exception occurred while processing the request. FormatException: String '13/12/2018' was not recognized as a valid DateTime. System.DateTimeParse.Parse(ReadOnlySpan s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
ReaderException: An unexpected error occurred. CsvHelper.Configuration.ConfigurationFunctions.ReadingExceptionOccurred(CsvHelperException exception)
The machine is using the Australian date which is dd/MM/yyyy format. It looks like Azure sets to American format one. How do we change this? Or how do force this into .Net core code configuration?
We also found that even we change the format of the date into ISO date: yyyy-MM-dd ... again worked OK on dev BUT not in Azure Production?
Any ideas?
Modified this and solved the problem:
var csvReader = new CsvReader(reader2);
csvReader.Configuration.CultureInfo = CultureInfo.GetCultureInfo("en-AU");
var records = csvReader.GetRecords<UploadBatchItem>();