6

My question is my title.

 Localization - how to get the client locale in asp.net mvc ?

I saw some posts regarding based on url routing, is there any way I can get the data from browser or from request to server and process. Is there any way to get the browser locale from asp.net. I am cretaing custom display attribute to handle localization as mentioned in this answer.

This is because I am using DB for keeping my localized values. My plan is to get the data and using Display Attribute , it will display the local values. I need the locale from browser. So is it possible to get the browser's locale and query before rendering based on it.

Thanks in advance.

Community
  • 1
  • 1
kbvishnu
  • 14,760
  • 19
  • 71
  • 101

1 Answers1

12

You can use: HttpRequest.UserLanguages Property : Gets a sorted string array of client language preferences.

Refer:

How to detect browser language

Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
  • 6
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – S.L. Barth is on codidact.com Oct 15 '12 at 13:33