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>