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
  • 13,576
  • 17
  • 66
  • 100

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,708
  • 2
  • 42
  • 51
  • 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 Oct 15 '12 at 13:33