Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

QueryStringValueProviderFactory uses InvariantCulture #5335

@MarcusKohnert

Description

@MarcusKohnert

Specific question:
Why does QueryStringValueProviderFactory use InvariantCulture to instantiate QueryStringValueProvider?

Other *ValueProviderFactory-classes use CultureInfo.CurrentCulture as I would have expected.


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

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'.

Actual
Response content is '01.01.0001'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions