diff --git a/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs b/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs index f890dd07b1..93046c53d4 100644 --- a/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs +++ b/samples/MusicStore/ForTesting/Mocks/StartupOpenIdConnectTesting.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; @@ -6,6 +7,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; @@ -113,6 +115,16 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // force the en-US culture, so that the app behaves the same even on machines with different default culture + var supportedCultures = new[] { new CultureInfo("en-US") }; + + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en-US"), + SupportedCultures = supportedCultures, + SupportedUICultures = supportedCultures + }); + app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage"); // Display custom error page in production when error occurs diff --git a/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs b/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs index c08db42f70..ffe81ad572 100644 --- a/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs +++ b/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Authorization; @@ -8,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; @@ -155,6 +157,16 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // force the en-US culture, so that the app behaves the same even on machines with different default culture + var supportedCultures = new[] { new CultureInfo("en-US") }; + + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en-US"), + SupportedCultures = supportedCultures, + SupportedUICultures = supportedCultures + }); + app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage"); // Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline. diff --git a/samples/MusicStore/Startup.cs b/samples/MusicStore/Startup.cs index 8b56692141..2ca1de0f34 100644 --- a/samples/MusicStore/Startup.cs +++ b/samples/MusicStore/Startup.cs @@ -1,7 +1,9 @@ +using System.Globalization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -170,6 +172,16 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // force the en-US culture, so that the app behaves the same even on machines with different default culture + var supportedCultures = new[] { new CultureInfo("en-US") }; + + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en-US"), + SupportedCultures = supportedCultures, + SupportedUICultures = supportedCultures + }); + // Configure Session. app.UseSession(); diff --git a/samples/MusicStore/StartupNtlmAuthentication.cs b/samples/MusicStore/StartupNtlmAuthentication.cs index f4ba919c19..136ea1a864 100644 --- a/samples/MusicStore/StartupNtlmAuthentication.cs +++ b/samples/MusicStore/StartupNtlmAuthentication.cs @@ -1,10 +1,12 @@ using System; +using System.Globalization; using System.Security.Claims; using System.Security.Principal; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -95,6 +97,16 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // force the en-US culture, so that the app behaves the same even on machines with different default culture + var supportedCultures = new[] { new CultureInfo("en-US") }; + + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en-US"), + SupportedCultures = supportedCultures, + SupportedUICultures = supportedCultures + }); + app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage"); // Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the diff --git a/samples/MusicStore/StartupOpenIdConnect.cs b/samples/MusicStore/StartupOpenIdConnect.cs index 07d0f4fd4d..649d436126 100644 --- a/samples/MusicStore/StartupOpenIdConnect.cs +++ b/samples/MusicStore/StartupOpenIdConnect.cs @@ -1,7 +1,9 @@ +using System.Globalization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -114,6 +116,16 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // force the en-US culture, so that the app behaves the same even on machines with different default culture + var supportedCultures = new[] { new CultureInfo("en-US") }; + + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en-US"), + SupportedCultures = supportedCultures, + SupportedUICultures = supportedCultures + }); + app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage"); // Display custom error page in production when error occurs