C# MVC Controller cannot get decimal or double values from Ajax POST request

This could be a Culture issue

Be sure that the string you are sending to your action is compliant to the current Culture. (check the decimal number separators . ,)

Exemple

e.g. on a french server, 99.1 will not be understood as 99,1, but will be converted to 0.

Solution

In that case, one solution is to define culture in your Web.Config

  <system.web>
    ...
    <globalization uiCulture="en" culture="en-US"/>
  </system.web>

Or, replacing the separator by the proper one on the client side.

Leave a Comment