none
ASP.NET - Determining user language if web server is in different region RRS feed

  • Question

  • Hello!

    I am trying to find out how to determine the user's language in an ASP.NET application. I have tried:

    tmpLanguage = HttpContext.Current.Request.UserLanguages
    

    It works like a charm. However, as my hosting provider (and the server) is in the US, English is shown as the language even if I run the page out of Europe. I would need to know the USER's language.

    Any advice is much appreciated.

    Best regards,

    Christian

    Thursday, September 28, 2017 11:51 AM

Answers

  • HttpContext.Current.Request.UserLanguages is an array of accepted languages by the user. When send, then there could be more than one. The first one is the preferred language.

    The region from where your requesting does not matter, only the settings of the users browser. It is taken from the Accept-Language header. So check the users browser settings.

    • Marked as answer by ChrisP1980 Friday, September 29, 2017 8:39 AM
    Thursday, September 28, 2017 12:11 PM

All replies

  • HttpContext.Current.Request.UserLanguages is an array of accepted languages by the user. When send, then there could be more than one. The first one is the preferred language.

    The region from where your requesting does not matter, only the settings of the users browser. It is taken from the Accept-Language header. So check the users browser settings.

    • Marked as answer by ChrisP1980 Friday, September 29, 2017 8:39 AM
    Thursday, September 28, 2017 12:11 PM
  • Hi CharisP1980,

    Since this forum is discussing and asking questions about the Visual Basic programming language, IDE, libraries, samples, and tools . And your issue is more related to asp.net. This link about asp.net, please refer that:

    https://forums.asp.net/

    Thank you for participating in the forum activities.

    Best Regards,

    Cherry



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 29, 2017 2:43 AM
    Moderator