diff --git a/src/CultureInfoGenerator/Program.cs b/src/CultureInfoGenerator/Program.cs index 9408009462..76882d3ce0 100644 --- a/src/CultureInfoGenerator/Program.cs +++ b/src/CultureInfoGenerator/Program.cs @@ -34,6 +34,7 @@ namespace CultureInfoGenerator // *************************** THIS FILE IS GENERATED BY A TOOL *************************** // To make changes to this file look at the CultureInfoGenerator project in this solution. +using System; using System.Collections.Generic; namespace Microsoft.Extensions.Globalization @@ -49,7 +50,7 @@ namespace Microsoft.Extensions.Globalization /// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it /// contains the latest culture names. /// - public static readonly HashSet KnownCultureNames = new HashSet + public static readonly HashSet KnownCultureNames = new HashSet(StringComparer.OrdinalIgnoreCase) {{" ); diff --git a/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoList.cs b/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoList.cs index 64cd81db0f..29c02b0e5c 100644 --- a/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoList.cs +++ b/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoList.cs @@ -4,6 +4,7 @@ // *************************** THIS FILE IS GENERATED BY A TOOL *************************** // To make changes to this file look at the CultureInfoGenerator project in this solution. +using System; using System.Collections.Generic; namespace Microsoft.Extensions.Globalization @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.Globalization /// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it /// contains the latest culture names. /// - public static readonly HashSet KnownCultureNames = new HashSet + public static readonly HashSet KnownCultureNames = new HashSet(StringComparer.OrdinalIgnoreCase) { "", "af", diff --git a/test/Microsoft.AspNet.Localization.Tests/QueryStringRequestCultureProviderTest.cs b/test/Microsoft.AspNet.Localization.Tests/QueryStringRequestCultureProviderTest.cs index 39fc682f8f..f9229864c5 100644 --- a/test/Microsoft.AspNet.Localization.Tests/QueryStringRequestCultureProviderTest.cs +++ b/test/Microsoft.AspNet.Localization.Tests/QueryStringRequestCultureProviderTest.cs @@ -167,5 +167,31 @@ namespace Microsoft.Extensions.Localization.Tests var response = await client.GetAsync("/page?c=ar-SA&uic=ar-YE"); } } + + [Fact] + public async void GetTheRightCultureInfoRegardlessOfCultureNameCasing() + { + using (var server = TestServer.Create(app => + { + var options = new RequestLocalizationOptions(); + var provider = new QueryStringRequestCultureProvider(); + provider.QueryStringKey = "c"; + provider.UIQueryStringKey = "uic"; + options.RequestCultureProviders.Insert(0, provider); + app.UseRequestLocalization(options); + app.Run(context => + { + var requestCultureFeature = context.Features.Get(); + var requestCulture = requestCultureFeature.RequestCulture; + Assert.Equal("fr", requestCulture.Culture.ToString()); + Assert.Equal("fr", requestCulture.UICulture.ToString()); + return Task.FromResult(0); + }); + })) + { + var client = server.CreateClient(); + var response = await client.GetAsync("/page?c=FR&uic=FR"); + } + } } } \ No newline at end of file