Culture in MVC RRS feed

  • Question

  • User52625461 posted

    Hello All,

    how to set the culture for entire mvc application without displaying the culture/language name in the URL like

    for english: www.example.com/user/create

    then if i change the language to french then the URL should be same,

    for french: www.example.com/user/create

    Only content should get displayed to French..

    How can I do this ?

    Thursday, October 16, 2014 1:58 AM

All replies

  • User197322208 posted


    Thursday, October 16, 2014 3:24 AM
  • User-1818759697 posted


    You could try removing the default "lang" value from the no language route, and adding a regex constant to the language route (For example allowing culture names like "en" or "en-US", check this question about a regex for culture names):

        name: "Default lang",
        url: "{lang}/{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        constraints: new { lang = @"[a-z]{2,3}(?:-[A-Z]{2,3})?" }
        name: "Default no language",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

    For more information, you could refer to:




    Monday, February 23, 2015 3:36 AM
  • User1622957740 posted

    You have to track the user's preference somewhere in your application - typically with a user profile and the based on that user profile change the Culture and UI Culture. If you don't use user profiles you might also keep the user preference in a Cookie or Session state, but regardless of what you do the choice has to be stored somewhere.

    If you do use a User profile you can hook the Culture selection into your Authentication process or into the Application_PostAuthenticateRequest pipeline event once you have the user and profile information. Once you have your user profile change the thread culture and uiculture to the user's specified language.

    +++ Rick ---

    Friday, April 17, 2015 4:50 PM