public void Execute(IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider) { serviceProvider = serviceProvider.CreateScope().ServiceProvider; RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions(); ICultureManager cultureManager = serviceProvider.GetService <ICultureManager>(); Culture frontendDefaultCulture = cultureManager.GetFrontendDefaultCultureAsync().Result; if (frontendDefaultCulture == null) { requestLocalizationOptions.DefaultRequestCulture = new RequestCulture(DefaultCulture.Id); } else { requestLocalizationOptions.DefaultRequestCulture = new RequestCulture(frontendDefaultCulture.Id); } if (cultureManager.GetNotNeutralCulturesAsync().Result.Count() == 0) { requestLocalizationOptions.SupportedCultures = requestLocalizationOptions.SupportedUICultures = new CultureInfo[] { new CultureInfo(DefaultCulture.Id) }.ToList(); } else { requestLocalizationOptions.SupportedCultures = requestLocalizationOptions.SupportedUICultures = cultureManager.GetNotNeutralCulturesAsync().Result.Select(c => new CultureInfo(c.Id)).ToList(); } if (serviceProvider.GetService <IConfigurationManager>()["Globalization", "SpecifyCultureInUrl"] == "yes") { requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider()); } applicationBuilder.UseWhen( context => !context.Request.Path.StartsWithSegments(new PathString("/backend")), frontendApplicationBuilder => { frontendApplicationBuilder.UseRequestLocalization(requestLocalizationOptions); } ); }