Loan
Loan
CC#
Created by Loan on 12/2/2023 in #help
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:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-975a6f23fd686e43f96af5532f544f5b-83eec17e49f1b737-00",
"errors": {
"Time": [
"The value '1572.752214' is not valid for Time."
]
}
}
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-975a6f23fd686e43f96af5532f544f5b-83eec17e49f1b737-00",
"errors": {
"Time": [
"The value '1572.752214' is not valid for Time."
]
}
}
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.
4 replies