Routes to use SEO friendly URLs with multiple languages enabled Setting

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 years ago
I just realise when this setting is enabled the routes in my plugin no longer worked
      
Seems one way to fix it was to create a second route for when the /xx/ country code is added to the front of the url

Original
endpointRouteBuilder.MapControllerRoute("Plugin.Completed",
"Plugin/completed/{orderId:regex(\\d*)}",
new { controller = "PluginCheckout", action = "PluginCompleted" });

Added
endpointRouteBuilder.MapControllerRoute("Plugin.Completed",
"{genericSeName}/Plugin/completed/{orderId:regex(\\d*)}",
new { controller = "PluginCheckout", action = "PluginCompleted" });

Do I have to duplicate and modify all my plugin routes or is there another way ?
2 years ago
No need to duplicate all routes, just use a language pattern for routes that lead to a specific page (not file download and not ajax requests). See an example of this approach in our plugin.
2 years ago
Thank you Sir!

route now changed to:

endpointRouteBuilder.MapControllerRoute(name: "Plugin.Completed",
                pattern: $"{lang}/plugin/completed/{{orderId:int?}}",
                defaults: new { controller = "PluginCheckout", action = "PluginCompleted" });
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.