Set CultureInfo in Asp.net Core to have a . as CurrencyDecimalSeparator instead of ,

后端 未结 6 982
清酒与你
清酒与你 2020-12-01 10:32

I\'m going mad. I just want the culture used in the entire Asp.net core application to be set to \"en-US\". But nothing seems to work. Where to I set the culture for the ent

6条回答
  •  余生分开走
    2020-12-01 10:37

    Only configuring in startup didn't work for me

     services.Configure(options =>
                {
                    var ksCultureInfo = new CultureInfo("sq");
                    var enCultureInfo = new CultureInfo("en");
                    var srCultureInfo = new CultureInfo("sr");
    
                    ksCultureInfo.NumberFormat.NumberDecimalSeparator = ".";
    
                    var supportedCultures = new[]
                    {
                        ksCultureInfo,
                        enCultureInfo,
                        srCultureInfo
                    };
    
                    options.DefaultRequestCulture = new RequestCulture(culture: enCultureInfo, uiCulture: ksCultureInfo);
                    options.SupportedCultures = supportedCultures;
                    options.SupportedUICultures = supportedCultures;
                    options.RequestCultureProviders = new List
                    {
                        new QueryStringRequestCultureProvider(),
                        new CookieRequestCultureProvider()
                    };
                }); 
    

    I added jquery globalize validation plugins: Then you need to use Globalize with jquery-validation-globalize plugin. Saw this here

    Now it works as expected.

提交回复
热议问题