Language Navigation TagHelper

Each multicultural website needs to have a reliable language navigation, here is a simple way to have functional language navigation dropdown for any .Net Core web application

The easiest way to create a language navigation for any dot net core web application.

install the nuget package :

Install-Package LazZiya.TagHelpers -Version 2.0.0


Add tag helpers to _ViewImports.cshtml

@addTagHelper *, LazZiya.TagHelpers


Add html tag wherever you need to create a language dropdown navigation:

<language-nav view-context="ViewContext"></language-nav>

Oooola :) the language navigation is ready!


LanguageNav tag helper creates the languages from supported cultures list, must be done in the startup.cs

see Localizing Request to learn how to add supported cultures, or follow Developing Multicultural WEb Application tutorial for more details about developing mıltilingual web applications in dot net core.


Live demo :


Required Parameters :

view-context :

  • Type: ViewContext
  • Values: ViewContext
  • Descripton : only required parameter is "ViewContext", must be passed in order to create navigation links with reference to the current page context' route values.


Optional Parameters :

render-mode :

  • Type: Enum of type LazZiya.TagHelpers.RenderMode
  • Values: Bootstrap, Classic
  • Default: Bootstrap
  • Description: Choose how to render the dropdown list, Bootstrap will create a div with anchor tags styled with bootstrap 4, or you can choose "Classic" to create a regular select form element.
  • Important note: Automatic page redirecting on language selection change is supported with Bootstrap mode only, in Classic mode you need to manually add javascript function to manage page redirection (see these solutions on stackoverflow)


culture-key-name :

  • Type: string
  • Default: "culture"
  • Description: The culture key name that is defined in the routing settings as {culture} to handle the selected culture name as en-US.


supported-cultures :

  • Type: list of comma seperated strings e.g. "en,tr,ar,hi,zh"
  • Default: null
  • Descripton: if this value is not defined, languages list will be created with reference to the supported cultures as defined in CultureInfo.SupportedCultures


language-label :

  • Type: Enum of type LazZiya.TagHelpers.LanguageLabel
  • Values: Name, DisplayName, EnglishName, NativeName, TwoLetterISOLanguageName
  • Default: EnglishName
  • Description: The text to display as language name in the dropdown list


redirect-to :

  • Type: Enum of type LazZiya.TagHelpers.RedirectTo
  • Values: HomePage, SamePage, SamePageNoQueryString
  • Default: SamePage
  • Description: Defines how to redirect the page when the language is changed


home-page-name :

  • Type: string
  • Default: Index
  • Description: if redirect-to is defined as HomePage then the home page name can be passed as additional parameter to create the navigation url