I am currently developing a web application in ASP.NET MVC Core where users should register. This is a localized web application that should be able to run for multiple languages. To be SEO friendly, I've chosen for routed localization, so my url's look like: https://localhost:5001/en/Catalogue or https://localhost:5001/fr/catalogue.
To allow this, I added this piece of code in my ConfigureServices method in Startup.cs
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddViewLocalization()
.AddDataAnnotationsLocalization();
In my Configure method I added this:
IList<CultureInfo> supportedCultures = new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("fr"),
};
var localizationOptions = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};
var requestProvider = new RouteDataRequestCultureProvider();
localizationOptions.RequestCultureProviders.Insert(0, requestProvider);
app.UseRouter(routes =>
{
routes.MapMiddlewareRoute("{culture=en}/{*mvcRoute}", subApp =>
{
subApp.UseRequestLocalization(localizationOptions);
subApp.UseMvc(mvcRoutes =>
{
mvcRoutes.MapRoute(
name: "areaRoute",
template: "{culture=en}/{area:exists}/{controller=Home}/{action=Index}/{id?}");
mvcRoutes.MapRoute(
name: "default",
template: "{culture=en}/{controller=Home}/{action=Index}/{id?}");
});
});
});
This works like a charm. I can translate my MVC pages in any flavour I want. My problem is with the identiy pages. I added those pages as scaffolded items. Their URL's are pointing to https://localhost:5001/Identity/Account/Register. Trying to access them with https://localhost:44339/en/Identity/Account/Register does not work. How can I implement routed localization with identity pages?
