I've a asp net core 2.0 web application with razor view. I've a grid with webapi datasource.
I've added and configured the UseRequestLocalization (in the Startup.Configure)
01.
var enUSCulture =
new
CultureInfo(
"en-US"
);
02.
var supportedCultures =
new
[]
03.
{
04.
enUSCulture,
05.
new
CultureInfo(
"it-IT"
)
06.
};
07.
08.
app.UseRequestLocalization(
new
RequestLocalizationOptions
09.
{
10.
DefaultRequestCulture =
new
RequestCulture(enUSCulture),
11.
// Formatting numbers, dates, etc.
12.
SupportedCultures = supportedCultures,
13.
// UI strings that we have localized.
14.
SupportedUICultures = supportedCultures
15.
});
In the _Layout.cshtml I've included the culture and messages javascript files
01.
@{
02.
var currentCultureString = System.Globalization.CultureInfo.CurrentUICulture.ToString();
03.
}
04.
05.
<
script
src
=
"~/lib/kendo-ui/js/cultures/kendo.culture.@(currentCultureString).min.js"
></
script
>
06.
<
script
src
=
"~/lib/kendo-ui/js/messages/kendo.messages.@(currentCultureString).min.js"
></
script
>
07.
08.
<
script
type
=
"text/javascript"
>
09.
kendo.culture('@currentCultureString');
10.
$(document).ready(function () {
11.
kendo.culture('@currentCultureString');
12.
//server culture: @System.Globalization.CultureInfo.CurrentCulture.ToString()
13.
//server ui culture: @System.Globalization.CultureInfo.CurrentUICulture.ToString()
14.
});
15.
</
script
>
I've verified the generated html and I can see the right culture (it-IT) with right datetime format both in display mode and inline edit mode (with datepicker in EditorTemplates). --> see the attachment
However when I click on save button, the put operation is done using en-US culture and goes wrong in the webapi --> see the attachment
Any idea as to what I am doing wrong?