ASP.NET Web API doesn't parse floating numbers with a '.'
Hi everyone, I have a quick question about ASP.NET
I am scratching my head over this for an hour now.
Why when I ask a simple float number in my controller and I give for exemple ''12.547" it does not get parsed and just returns to the calling client this response:
It might be a culture problem, because my computer is in french, and floating numbers are formatted like '12,547' for example.
But I did not find any way of telling ASP to use the en-US culture.
Any idea? Thank you so much.
3 Replies
I am not an asp.net expert, but you could try adding this shortly before your web host runs (in Program.cs perhaps?)
From this SO post
Stack Overflow
Set CultureInfo in Asp.net Core to have a . as CurrencyDecimalSepar...
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 entire application? I'm not
I am going to end my life ðŸ˜
You are right, I tried by setting the
CultureInfo.CurrentCulture & CultureInfo.CurrentUICulture
(which is not working)
But I haven't though about the THREAD Culture... because ASP is multi threaded
Anyway, works like a charm now, thank you so much, I'll stop wasting time on this 😅