ASP.NET Core 2.2.0
I'm looking for language-based urls in ASP.NET Core. Found a lot of examples online for .NET Core MVC, but can't get it working in Razor Pages.
What I want to achieve is:
- domain.com/informatie -> link to the 'information' page in default language (Dutch for me)
- domain.com/en/information -> link to same the same page in English
Therefor I need 2 features:
- Recognize the language in the url, or set default language when language-tag is not provided
- Translate the names of my Pagemodels
I will write a custom method for translating the content.
Best fitting example
I found 2 examples that do almost the same I want, but they are using MVC:
- ASP.NET Core: Simple localization and language based URL-s
- Localized routing using ASP.NET Core MVC 2
The second one looks great, I tried to rewrite it for Razor Pages, but got stuck on the LocalizationController.cs
(since I'm not using a controller, but a Pagemodel) CultureActionLinkTagHelper.cs
(I use the asp-page attribute).
Is there anybody who has fixed this in Razor Pages and who would like to share the code? Or anybody who can help me through?