C
C#9mo ago
Zerthz

MVC model binding issues

Hello, I got some issues with model binding for my MVC endpoint. All doubles fail and become 0/null. I went into the model state to check what was wrong, and it said that it had an invalid value. The value had a period in it as the separator. I copied the exact value the model state said was invalid and placed it into the local and it was accepted no problem. Have anyone seen an issue like this? What would you recommend to deal with it, a custom binder?
3 Replies
Angius
Angius9mo ago
Probably because of culture issues In some cultures, the decimal separator is a comma If the app uses that culture, parsing a string with a number that uses a period for a decimal separator will fail
Zerthz
ZerthzOP9mo ago
But wouldn't it tell on me when I put the "faulty" incoming value into the local value and continue the process? Right now it accepts the value and moves on. It just won't accept it in the binding
Angius
Angius9mo ago
Do you check the model state?
Want results from more Discord servers?
Add your server