Search code examples
asp.net-core-2.0model-bindingwindows-server-2016

Losing 0at the beginning at object binding


Hello guys I have a code that I am using to send some locations(coordinates between 0 and 1) however even the results created properly at the frontend while I am binding them to my model at behind I am losing 0 at the beginning. 0.2534554 becomes 2534554 and 0,2500000 becomes 25. That is my problem.

You can see my model and controller below My model

public class FileUpload
{
    [Required]
    public IFormFile picture { get; set; }
    [Required]
    public int[] klass { get; set; }
    [Required]
    public double[] normloc_top { get; set; }
    [Required]
    public double[] normloc_left { get; set; }
    [Required]
    public double[] normloc_bottom { get; set; }
    [Required]
    public double[] normloc_right { get; set; }

}

My controller

    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<IActionResult> Create(FileUpload file)
    {
        ...
    }

What should I do about that it works on my local perfectly but not on the windows 2016 server If you can help me I apprecate that. Thank you.


Solution

  • It might be because of your windows time, currency settings go to control panel >> clock and region >> change date time or number formats be sure you are using the dot(.) for seperation between 0 and other numbers in your settings. If your user group something else than admin use this settings for all users in the administrative settings >> copy settings