I have the following MVC ViewModel:
public class Payment
{
[Required]
[Range(5, 1000)]
public decimal RebillAmount { get; set; }
}
When I have switched the application language to French Canadian using:
var cultureInfo = new CultureInfo("fr-CA");
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
Then submit a decimal with 300,00
in the input field, the value for the decimal is converted to 30000
when retrieving the value in my controller?
For example:
public ActionResult Save(Payment model)
{
decimal amount = model.RebillAmount; // <- Returns 30000, not 300.00
}
What am I doing wrong?
EDIT:
The culture is set manually for testing (as shown above), but it's actually configurable by each user using a session variable.