You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
public void Configure(IApplicationBuilder app)
{
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("de-DE")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("de-DE"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
app.UseMvcWithDefaultRoute();
}
SampleController.cs
public class SampleController : Controller
{
public IActionResult Action(DateTime dateParameter)
{
return this.Content(dateParameter.ToShortDateString());
}
}
Expected:
DateTime parameter 'dateParameter' is properly bound and response content is '28.09.2016'.
Specific question:
Why does QueryStringValueProviderFactory use InvariantCulture to instantiate QueryStringValueProvider?
Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/QueryStringValueProviderFactory.cs
Line 28 in a78f77a
Other *ValueProviderFactory-classes use CultureInfo.CurrentCulture as I would have expected.
Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs
Line 45 in a78f77a
Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/FormValueProviderFactory.cs
Line 41 in a78f77a
Problem Scenario:
Request:
GET http://localhost:5000/sample/action?dateParameter=28.09.2016
Accept-Language: de-DE
The query parameter is a date in german format.
Startup.cs
SampleController.cs
Expected:
DateTime parameter 'dateParameter' is properly bound and response content is '28.09.2016'.
Actual
Response content is '01.01.0001'.