0

In sturtup i use:

 var locale = "ru-RU";
            RequestLocalizationOptions localizationOptions = new RequestLocalizationOptions
            {               
                SupportedCultures = new List<CultureInfo> { new CultureInfo(locale) },
                SupportedUICultures = new List<CultureInfo> { new CultureInfo(locale) },
                DefaultRequestCulture = new RequestCulture(locale),
            };

In this controller:

[HttpPost] 
        public async Task<IActionResult> Test(SearchModel searchModel)
        {
           decimal sum = searchModel.Sum;
        

work true, but when i get decimal in query params localization not work:

[HttpGet]
        public async Task<IActionResult> Index(decimal? sum)
        {
           decimal sum_ = sum;//when i enter 1,2 controller in sum_ 12.0
  • you should enter 1.2 with dot. It is decimal. – daremachine Dec 17 '20 at 04:52
  • no in first controller 1,2 its decimal, in russian localization comma is separator, but in second controller its incorent work – RussianPupok Pupok Dec 17 '20 at 04:52
  • 1
    so you try parse with your culture like here https://stackoverflow.com/questions/23131414/culture-invariant-decimal-tryparse – daremachine Dec 17 '20 at 04:54
  • Note that the question is asking how to use correct culture for model binding (and hopefully a way shown in the [duplicate](https://stackoverflow.com/questions/44688311/how-to-set-culture-for-date-binding-in-asp-net-core) is correct), if that is not what you are looking for please [edit] question so readers are not confused. – Alexei Levenkov Dec 17 '20 at 06:06

0 Answers0