Api receives date with month and day changed if the parameter is sent by the url

0

I have an api that receives a date (the date is sent as a string and received as DateTime):

    [HttpPost("ObterDados")]
    public JsonResult ObterDados(DateTime data)
    {
       //codigo

If I make the post with the parameter in url the date is received with the month and day reversed (get mm / dd / yyyy)

    $.post("/api/ObterDados/?data=" + self.Data...

If I send the date inside an object it is received correctly (receives dd / mm / yyyy)

    var objeto = {data: "15/12/2017"}

    $.post("/api/ObterDados/", objeto....

    [HttpPost("ObterDados")]
    public JsonResult ObterDados(Filtro filtro)
    {
       //codigo

Why does this happen and have some way to always receive the date as dd / mm / yyyy?

Note: The date is always sent as a string

Statup class configuration:

        var requestLocalizationOptions = new RequestLocalizationOptions
        {

            SupportedCultures = new List<CultureInfo>
            {
                new CultureInfo("pt-BR")
            },
            SupportedUICultures = new List<CultureInfo>
            {
                new CultureInfo("pt-BR")
            },

            DefaultRequestCulture = new RequestCulture("pt-BR", "pt-BR"),
        };

        app.UseRequestLocalization(requestLocalizationOptions);

Web.config:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <system.webServer>
      <handlers>
        <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
      </handlers>
      <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
    </system.webServer>
  </configuration>
    
asked by anonymous 15.12.2017 / 18:20

1 answer

0

After following several tutorials, having tried several ways to correct this by configuring the application, the best option was to create a component using vue.js, for inputs that are data. It formats the date in dd / mm / yyyy on the screen but in value the date is in the format yyyy / mm / dd. So I do not need to use functions every time I send the date to the api.

    
18.12.2017 / 14:04