If user submit price value (decimal / int) empty from view, server side model validation show wrong message.
There is issue found on model validation server side.
public string Genre { get; set; } public decimal Price { get; set; }
If user submit price value empty from view, server side model validation show wrong message ie. the value "" is not valid.
I have checked in controller, the incoming model is showing price value 0 as default but ModelState getting rawValue="". so conflicting with datatype and throw msg. Please resolve the above issue.
The SimpleTypeModelBinder detects that string.Empty cannot be converted to a decimal value and adds the error you see. What is the issue?
ok SimpleTypeModeBinder is detecting string.empty but model is carring 0 as default (even user submit with empty) so should validate with 0 not with "" (string.empty).
front javascript validation working fine but server side model validation show wrong error message as "the value "" is not valid"
decimal / int is alwasys getting 0 as default value.
Thanks for prompt reply
We're talking about a model binding error -- some invalid data on the wire gets caught up front. Validation and default values for properties that aren't assigned aren't relevant here.
In MVC5 its working fine but in MVC6 its showing error like above mentioned.
Either MVC 5 did not show the same error in this situation or it didn't catch the error. Either way, the MVC 6 behaviour is correct -- the submitted value "" is not valid for a decimal property.
More generally why do you prefer a different behaviour? What is your overall scenario that requires this problem not be caught?
For example, if you prefer the model binding problem is ignored, clear the errors for that property in the ModelStateDictionary.
Thank u very much. Problem solved I have identified the cause of problem.