Emerging Expert

Total Ranking points:70

Top Questions

3 Getting 415 "Unsupported Media Type" on post request from reactjs to asp.net core apicontroller ?

Top Answers

3 You need to make following changes to your code and it will fix the problem. First of all you need to use the CultureInfo.InvariantCulture which make sure that you will have same date with both English and Arabic. string startDate= sourceEvent?.Fields.EventStart.ToString("dd.MM.yy" , CultureInfo.InvariantCulture); string endDate= sourceEvent?.Fields.EventEnd.ToString("dd.MM.yy" , CultureInfo.InvariantCulture); Secondly you need create the following method to convert the English digits to Arabic digits in case we have Arabic culture private string ConvertNumerals(string input) { if (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ar") { return input.Replace('0', '\u06f0').Replace('1', '\u06f1').Replace('2', '\u06f2').Replace('3', '\u06f3').Replace('4', '\u06f4') .Replace('5', '\u06f5').Replace('6', '\u06f6').Replace('7', '\u06f7').Replace('8', '\u06f8').Replace('9', '\u06f9'); } else return input; } So your final code will look like the following one, where you can call the ConvertNumerals method. string startDate= ConvertNumerals(sourceEvent?.Fields.EventStart.ToString("dd.MM.yy" , CultureInfo.InvariantCulture)); string endDate= ConvertNumerals(sourceEvent?.Fields.EventEnd.ToString("dd.MM.yy" , CultureInfo.InvariantCulture));

Top Tags Created

2 ASP.NET Core

2 HTTP response status codes

1 415 Unsupported Media Type

Top Tags Used

2 C#

1 ASP.NET MVC

1 React.js

1 ASP.NET Core

1 415 Unsupported Media Type

1 HTTP response status codes

1 DateTime Format