Share via

.NET Blazor Routing

Kuler Master 411 Reputation points
2024-02-27T22:25:09.26+00:00

Hello, I have a razor page named Contact.razor. I want to localize it so when you select one of the 3 languages, the route changes accordingly. Meaning, I don't want to only change the culture but also the route. For example, by default it is /en/contact and I want to, when I click to IT item in the dropdownlist, change to /it/contatto. Is this doable at all? @page "{language}/Contact" @page "{language}/Kontakt" @page "{language}/Contatto" Thank you

Developer technologies | .NET | Blazor
Developer technologies | ASP.NET Core | Other

1 answer

Sort by: Most helpful
  1. Kuler Master 411 Reputation points
    2024-02-28T07:40:23.0266667+00:00

    Actually my question is about the link. How do I form the HREF in order to make it showing correct route according to the language e.g.

    <a class="nav-link" href="@CultureInfo.CurrentCulture.TwoLetterISOLanguageName/@_localizer["Route_Contact"]">@_localizer["Link_Contact"]</a>
    
    

    Thank you Solved. Thank you!

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.